🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #54

Re: Single Instance Application

#54
From: Paul Nichols (TeamB)
Date: Wed, 23 Feb 2005 14:59
29 lines
2249 bytes
"Eric Orilla" <eorilla@hotmail.com> wrote in message
news:421c464c$1@newsgroups.borland.com...
>
Here's how I would do it to ensure XPlatform.

When the application starts, read from a configuration file (XML, Properties
file, whatever you wish). Look for a runtime value (call it AppRunning,
Running, IsRunning, etc). If the value of the param is true, create a
message starting that the application is currently running. You might want
to add an override feature just in case the application/OS locked up or
crashed.

If, on startup, the value is null, false, etc. set the parameter/entity to
true, once the application has launched. This would ensure that only one
instance is running.

Other than this, as Kevin stated, there is no other way to do this and
ensure XPlatform. If that is not important to you, and let's say you need to
support Windows and not MAC or Unix, then you will need to call a Windows
API.

Here is some information on creating a single instance app using C++Builder.
You could create this app and use it to run your Java application, or use
JNI in the program and in your Java code. However, if you use this as a
wrapper for your Java code, you will have to ensure that the jar file is not
runnable and you will need to create a custom class loader mechanism.

Hope this helps ya!!
Technical Details
Message-ID: <421c9a58$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <421c464c$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1089d0,4423778dca7c940b
X-Google-Attributes: gid1089d0,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Paul Nichols \(TeamB\)" <paul@computer-logic.net>
Newsgroups: borland.public.jbuilder.java.api
References: <421c464c$1@newsgroups.borland.com>
Subject: Re: Single Instance Application
Date: Wed, 23 Feb 2005 08:59:37 -0600
Lines: 31
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 66.20.208.2
Message-ID: <421c9a58$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1109170776 66.20.208.2 (23 Feb 2005 06:59:36 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail