Single instance application...

I have developed an application that takes custumized protocol links from a web page. I had to write a registry key to invoke the program but I have succeded.

Here is the scenario:
just like http, ftp, and ed2k links, I have written a registry key so that if a URL in a web page contains a specific protocol lets say "myapp" as in
<a href="myjavaapp://|parameter_1|......|parameter_n|">Click here</a>
"myjavaapp" is invoked and from the link above receives the parameters.

My Problem:
If "myjavaapp" is not running there is no problem. The application is started.
If "myjavaapp" is already running a new instance of the program is run. So I have two copies of the same program running on my desktop.
What should I do to make this program run in one instance? I have been told to create a file on startup of the application and delete when exited, but incase my application crashes the file would not be deleted, thus if I check the existanse of that file, since it would exist from a previous crash, the application would not run.

So what should I do other than "creating and deleting a file upon start and exit" option?
 
DigiTechinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

armoghanCommented:
Hi DigiTechin,
this may help
http://mindprod.com/jgloss/singleinstance.html

Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DigiTechinAuthor Commented:
armoghan,

I already seen those. They both talk about locking a file, which is not what I intend to do.
My problem resides. If the program crashes, for one reason or another, I would get stuck.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

sciuriwareCommented:
That's not true: a lock vanishes if the program stops!
<*>
0
armoghanCommented:
sciuriware is write the lock finishes..
the other option is open a serverSocket, That is also the same as locking a file.
0
sciuriwareCommented:
Thanks for your support armoghan, but please say "sciuriware is right" in stead of "write"
otherwise I feel a file myself.
Haha.
I found that the file locking works on all platforms in the world and has
some advantages: the locker can write some identification in the lock file.
That means that, again system independent, the system manager can findout
where such a file belongs to: it's very hard to find socket-locks in a living system.
One application: can you take a system down, knowing that all locking applications
have left? From the socket-method you couldn't tell; from the lock-method you can.
<*>
0
armoghanCommented:
hahaha .
Thanx for correcting
Sorry sciuriware

My english is not that good and I scramble words while writing
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.