Hi guys! I am in trouble. I created program using Java. Exported into JAR. When I started my jar file, program works, ok. But when I try to launch again without closing previous one, then it runs. So how to disable this?
One trick that's often used is for your program to try to open a ServerSocket on a specific port. If it succeeds, then go ahead and run the application. If it fails, then immediately exit. This way, only one copy of your application can run at a time. You can try to do similar things by creating a temporary file and checking for its existence, but this is harder to get right, especially on Windows.