title: Figure out if a jar is running -- NOT OS Dependent
body: <p>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 <code>java -jar</code> </p>
  
  <p>I looked into the following:  <a href="https://stackoverflow.com/questions/3844168/how-can-i-check-if-a-unix-process-is-running-in-perl">How can I check if a Unix process is running in Perl?</a> However it did not seem to work for Windows.</p>
  
  <p>I also looked at this post:  <a href="https://stackoverflow.com/questions/1023781/using-perl-how-do-i-check-if-a-process-with-given-name-is-running-or-not">Using Perl, how do I check if a process with given name is running or not?</a>  However this would only work for Windows.</p>
  
  <p>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.</p>
  
  <p>Any help would be great.</p>