Re: only one instance



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




.



Relevant Pages

  • Re: Problem when connecting Java App with C++ App using Windows So
    ... For the same WAN environment which socket error problem between the 2 ... first, maybe the Java App program problem, the other is ... the cooperation issue between C++ socket and Java socket (both are in Windows ... tool to check why the Java app often detects socket error. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Async Socket IO Question
    ... I think you're mostly bumping into Socket Timeout issues. ... If you kill the process of your client app, the TCP session isn't cleanly ... When your server sends to the client app, that send happens just fine (the ...
    (microsoft.public.dotnet.framework)
  • Re: Linux and OS wide events
    ... I am new to Linux programming. ... app that needs to dispatch events using C++. ... Registration requests will cause the socket the request appeared on to be added to the list of sockets messages of the requested kind will be "broadcasted" to. ...
    (comp.os.linux.development.apps)
  • CPU Usage 100%
    ... Socket connection, ... the refresh timers are only initiated when the data has been ... When I start the app, ... it seems my message handling procedure and it's ...
    (microsoft.public.win32.programmer.kernel)
  • CPU Usage 100%
    ... Socket connection, ... the refresh timers are only initiated when the data has been ... When I start the app, ... it seems my message handling procedure and it's ...
    (microsoft.public.win32.programmer.networks)