Jcmd command, jcmd command
Overview
After JDK 1.7, a command line tool jcmd is added. It is a multi-function tool that can be used to export heap, view java processes, export thread information, and execute GC.
Example
The following command lists all running virtual machines:
The-l parameter lists all Java virtual machines. For each virtual machine, you can use the help command to list all commands supported by the virtual machine, as shown in. Take the process 21024 as an example:
View VM startup time VM. uptime
Print Thread stack information Thread. print
View the class statistics in the system. GC. class_histogram
Run the following command:
[Qifuguang @ Mac ~] $ Jcmd 21024 GC. class_histogram
The result is as follows:
Export heap information GC. heap_dump
Use the following command to export the current stack information: this command function and jmap-dump
Same functions
Get System Properties content VM. system_properties
Obtain the startup parameter VM. flags
Obtain all performance-related data: PerfCounter. print
Summary
As shown in the preceding example, jcmd has most of jmap functions, and Oracle officially recommends using jcmd instead of jmap.