So i have packaged my project as a single executable jar that works fine. But at times it happens that the user launches the file multiple times, and this causes it to launch multiple instances of same project (causing unexpected behavior e.g overwriting values in files by delayed instances of project).
I want to know for a windows platform (Win7), what are the options to lock the execution for only one time, and then if the jar is already running, simply don’t proceed executing the code again.
I read about Process ID’s but if there are multiple java app’s they all end up showing imagename as javaw.exe and how can i determine own process id??
Please suggest what is the proper way of doing this thing, thank you!!
The simplest solution is to use a fixed, unused port.