简体   繁体   English

如何区分正在运行的Java程序

[英]How to distinguish running java programs

Our server machine runs many java programes. 我们的服务器计算机运行许多Java程序。 And some of them are launched with the command "java -jar ***.jar". 其中一些是使用命令“ java -jar ***。jar”启动的。 but sometimes I have to stop one to update the class files in it. 但有时我必须停止更新其中的类文件。 the problem is how can i fingure out which program is the one i want to stop, or is there a tool I can use to find out the executable jar files' location. 问题是我如何确定要停止的程序是哪个,或者是否有工具可以用来查找可执行jar文件的位置。

You can use jps command. 您可以使用jps命令。

$ jps -v
34370 Jps -Dapplication.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home -Xms8m
34341 main -XX:+TieredCompilation -Xbootclasspath/a:/usr/local/Cellar/leiningen/2.5.0/libexec/leiningen-2.5.0-standalone.jar -Dfile.encoding=UTF-8 -Dmaven.wagon.http.ssl.easy=false -Dleiningen.original.pwd=/Users/ntalbs/js-workspace/synapeditor_mobile -Dleiningen.script=/usr/local/bin/lein

jps will display all java processes. jps将显示所有Java进程。 The first column is OS pid. 第一列是OS pid。 You can check the messages on console, then kill what you want. 您可以在控制台上检查消息,然后杀死所需的消息。 Perhaps you want to check jps document from Oracle. 也许您想从Oracle检查jps文档

Also, you can use ps and grep command. 另外,您可以使用psgrep命令。

$ ps -ef | grep java

or 要么

$ ps -aux | grep java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM