When I run my application using the .jar file, the GUI is displayed and javaw.exe shows up in System Processes in the task manager. But when I run the .jar file again without closing the first one, a second javaw.exe process starts and a second GUI is displayed. How do I stop this? I want there to be only one instance of my application at a time no matter how many times I run the .jar file.
Asked
Active
Viewed 189 times
3 Answers
1
One simple way is to open a socket on a fixed port number. The OS will enforce that only one process may do this.
Bohemian
- 389,931
- 88
- 552
- 692
-1
Register a value in a file, is probably the easiest solution.
Johan Frick
- 1,004
- 1
- 10
- 17
-
In case of crash of the program, how will you again start the application? – shiv.mymail Jun 03 '16 at 05:08