After a research in google i found good answers like:
1)using jps or jps -l to get the jars running under JVM
OK with this answer but if the user has not java installed at all and i run my jar using for example a .bat file and a folder with java JRE.
Also gps function is experimental and only JDK contais it and not JRE.
2)Check if jar running from shell
I need a solution for this on windows platform.Although a platform indepedent solution is always prefferable.
Something more about jps(cause it is Platform Independent) I will appreciate an answer where you provide me a good solution with jps function.
A . jar file contains compiled code (*. class files) and other data/resources related to that code. It enables you to bundle multiple files into a single archive file.
Most JAR files are simply containers for data that another program needs to run with Java; therefore you cannot run these files and nothing will happen when you double-click them. Similarly, most executable JAR files are downloaded as installation files to install applications or programs.
Jar files (Java ARchive files) can contain Java class files that will run when the jar is executed. A jar is an archiving format that not only stores directories and source files, but can be run as an executable as well.
use this command to check the jar is running or not.
ps aux | grep java
eg:
sys_name 7526 60.1 2.6 4474364 104092 pts/4 Sl+ 23:57 0:09 java -jar start.jar
You can us ps
and grep
on a *nix system as described above. For windows you can do:
tasklist /v /FI "IMAGENAME eq java.exe"
This will get you a list of all the Java programs running. I don't think you can get much closer on Windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With