I am looking for a solution to figure out if my .jar is already running. However, I need this to be able to work on Windows, RedHat, Solaris, OEL, etc. A solution in perl would be great. However, I would also be okay trying a solution where the jar is called and then in the main class checks to see if another jar is already running (and if it is, it shutsdown). I am calling it using java -jar
I looked into the following: How can I check if a Unix process is running in Perl? However it did not seem to work for Windows.
I also looked at this post: Using Perl, how do I check if a process with given name is running or not? However this would only work for Windows.
I suppose it would be possible to use a combination of the two after figuring out which OS the jar is running on, however I am looking for a 'cleaner' option.
Any help would be great.