Introduction to jps
Use jps to view the running Java process ID. The Java process ID queried by jps is consistent with the process ID of the operating system.
Parameter explanation
content | illustrate |
---|---|
-q | Only display LVMID (local virtual machine id), that is, the unique id of the local virtual machine, not the name of the main class |
-l | Output the full class name of the main class, if the jar package is executed, output the full name of the jar package |
-m | Output parameters passed to main() when the virtual machine process is started |
-v | List the JVM parameters when the virtual machine process is started |
Example of use
1) Print the full class name: jps -l
2) Print the parameters passed to main(): jps -m
public class ParamTest {
public static void main(String[] args) throws InterruptedException {
if(args.length>0) {
System.out.println(Arrays.toString(args));
} else {
System.out.println("no args");
}
Thread.sleep(5000000);
}
}
3) Print the JVM parameters when the virtual machine process starts: jps -v
Precautions
If the -XX:-UsePerfData parameter is added when the JVM is started, jps cannot monitor it.
java -XX:-UsePerfData -Xmx8m -jar ParamTest.jar hello