功能
jps(Java Virtual Machine Process Status Tool)是JDK 1.5提供的一个显示当前所有java进程pid,启动命令和参数的命令。
The jps command uses the java launcher to find the class name and arguments passed to the main method. If the target JVM is started with a custom launcher, the class name (or JAR file name) and the arguments to the main method will not be available. In this case, the jps command will output the string Unknown for the class name or JAR file name and for the arguments to the main method.
原理
java程序在启动以后,会在java.io.tmpdir指定的目录下,生成一个类似于hsperfdata_<UserName>的文件夹,其中有几个文件,名字就是java进程的pid,这个文件夹是与当前用户关联的,所以jps仅查找当前用户的Java进程,而不是当前系统中的所有进程。
java.io.tmpdir的位置可以用如下命令显示:
mvn help:system |
OPTIONS
-m Output the arguments passed to the main method. The output may be null for embedded JVMs.-l Output the full package name for the application's main class or the full path name to the application's JAR file.-v Output the arguments passed to the JVM. |
示例
jps -m jps -l |