Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

only one instance

Thread view: 
Chameleon - 30 Oct 2005 12:11 GMT
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
Thomas Hawtin - 30 Oct 2005 12:48 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.