Re: only one instance
- From: steve <steve@xxxxxxx>
- Date: Mon, 31 Oct 2005 05:15:05 +0800
On Sun, 30 Oct 2005 19:48:23 +0800, Thomas Hawtin wrote
(in article <4364b268$0$49809$ed2e19e4@xxxxxxxxxxxxxxxxxxxxxxxxxx>):
> Chameleon wrote:
>> I want only one running instance of my app.
>
>
>> 1. sockets
>> 2. locking files (I prefer this)
>
>
>> When I run the 2nd instance of App with a file parameter:
>>
>> my_app.jar a_file.txt
>>
>> I want to pass "a_file.txt" to 1st instance for opening and then 2nd
>> instance terminate.
>
> The obvious solution is to use the socket method of running a single
> instance of the app. The second app then connects to the socket and
> transfers the filename.
>
> Tom Hawtin
>
I sometimes get problems with the socket approach, if the main app shuts down
for some reason (and does not kill the signaller),the socket app ( running in
another thread) holds the jvm open ,and requires a 3 finger salute.
otherwise it prevents the user from re-starting a new app.
the another way is to get the program to write a java "temp" file to a
directory with no other file in.
then when you start the app, count the files in that directory.
( i have not yet seen java NOT clean up it's temp files)
Do not create a "Normal user file", but a Java TEMP file.
Steve
.
- References:
- only one instance
- From: Chameleon
- Re: only one instance
- From: Thomas Hawtin
- only one instance
- Prev by Date: Re: ++i is faster than i++ in Java?
- Next by Date: Re: Thunerbird help... [not java related , but please help if you can!]
- Previous by thread: Re: only one instance
- Next by thread: How stable is 1.5?
- Index(es):
Relevant Pages
|