I want only one running instance of my app.
There are 2 methods:
1. sockets
2. locking files (I prefer this)
But my big problem is 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.
How can I do this?
sorry for my english
and thanks
> 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

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
steve - 30 Oct 2005 22:15 GMT
>> I want only one running instance of my app.
>
[quoted text clipped - 13 lines]
>
> 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