How do I find out if a specific JAR file is running on my machine or not? I just want to ensure that a specific JAR is only executed once at any time-- so if another request
jps is a simple command-line tool that prints out the currently running JVMs and what they're running. You can invoke this from a shell script.
jps -l
will dump out the JVM process id and the main class that it's executing. I suspect that's the most appropriate for your requirement.
Noting your comment re. jps being not supported, if it's a valid worry that you can't easily mitigate via testing when you upgrade a JDK/JRE, then perhaps use something like:
pgrep -lf java