如何知道一个jar文件是否已经在运行? [英] How to know if a jar file is already running?
问题描述
确定这个答案,但是如果用户根本没有安装java并且我使用例如.bat文件运行我的jar,一个包含java JRE的文件夹。
另外gps函数是实验性的,只有JDK包含它而不是JRE。
我需要一个针对windows平台的解决方案。虽然独立平台的解决方案始终是可预测的。
更多关于jps( cause它是独立于平台的)我会很高兴为您提供一个答案,您可以通过 jps 函数为我提供一个很好的解决方案。 解决方案
您可以在* nix系统上将 ps
和 grep
作为如上所述。你可以这样做:
tasklist / v / FIIMAGENAME eq java.exe
这将为您提供所有正在运行的Java程序的列表。我不认为你可以在Windows上靠得更近。
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.
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.
这篇关于如何知道一个jar文件是否已经在运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!