Brief introduction
The longest one to use.
The same functionality as the View Java Process command in Linux:
PS grep Java
The difference between JPS and this command is that JPS simply filters out the process of Java itself and the running boot class, which is the class that guides the main method.
Use
- -Q outputs only VM identifiers, excluding class Name,jar name,arguments in Main method
- -M output Main method parameters
- -L outputs the full package name, applies the main class name, and the full path name of the jar
- -V Output JVM parameters
- -V outputs the parameters that are passed to the JVM by the flag file (the. hotspotrc file or the file specified by-xx:flags=
- -joption Pass parameters to the VM, for example:-j-xms48m
Give me a chestnut??
Write a Java class to emulate the implementation of JPS:
1 Package service.test;2 3 import Com.sun.tools.attach.VirtualMachine;4 import Com.sun.tools.attach.VirtualMachineDescriptor;5 6 import java.util.List;7 8 /**9 * Created by Zhengbin on 16/8/30.Ten */ One Public class Jpstest { A Public static void Main (string[] args) throws Interruptedexception { -List<virtualmachinedescriptor> machinedescriptors =virtualmachine.list (); - for(Virtualmachinedescriptor machinedescriptor:machinedescriptors) { theSystem.out.println (Machinedescriptor.ID() +"\ t"+machinedescriptor.displayname ()); - } -Thread.Sleep(Ten* +); - } +}
Operation Result:
Execute the JPS command at the same time:
The execution result is the same as the jps-m command execution result.
Common Java Tools--jps