I only want one instance of my program running. But I want it to close the older ones, if they ore open.
This is in Java.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use a server socket address as an exclusive lock.
When your app starts, it will try to bind a server socket to a predefined address. If that fails, it means a previous instance of app is running and owning that address. Ping that address to tell the owner to exit.
It’s easy to shut down your app from command line