jcmd命令实战讲解
//用于显示java中当前正在运行的线程 C:\Users\admin>jps -help usage: jps [-help] jps [-q] [-mlvV] [<hostid>] Definitions: <hostid>: <hostname>[:<port>] C:\Users\admin>jps 5600 Launcher 9808 Launcher 7812 Jps 4104 5308 RemoteMavenServer //常用jps -l C:\Users\admin>jps -l 5600 org.jetbrains.jps.cmdline.Launcher 9808 org.jetbrains.jps.cmdline.Launcher 4104 2332 sun.tools.jps.Jps 5308 org.jetbrains.idea.maven.server.RemoteMavenServer
-
jcmd命令
- jcmd(从JDK1.7开始增加的命令)
- ① jcmd pid VM.flags :查看JVM的启动参数
- ② jcmd pid help :列出当前运行Java进程可以执行的操作
- ③ jcmd pid help [JFR.dump]:查看具体命令的选项
- ④ jcmd pid PerfCounter.print:查看JVM性能相关参数
- ⑤ jcmd pid VM.uptime : 查看JVM的启动时长
- ⑥ jcmd pid GC.class_histogram :查看系统中类的统计信息
- ⑦ jcmd pid Thread.print :查看线程的堆栈信息
- ⑧ jcmd pid GC.heap_dump filename:导出Heap dump 文件,导出的文件可以通过jvisualvm查看
- ⑨ jcmd pid VM.system_properties :查看JVM的属性信息
- ⑩ jcmd pid VM.version:查看目标JVM进程的版本信息
- 11.jcmd pid VM.command_line :查看JVM启动的命令行参数信息
- jstack:可以查看或是导出Java应用程序中线程的堆栈信息
- jcmd(从JDK1.7开始增加的命令)
C:\Users\admin>jcmd -help Usage: jcmd <pid | main class> <command ...|PerfCounter.print|-f file> or: jcmd -l or: jcmd -h command must be a valid jcmd command for the selected jvm. Use the command "help" to see which commands are available. If the pid is 0, commands will be sent to all Java processes. The main class argument will be used to match (either partially or fully) the class used to start Java. If no options are given, lists Java processes (same as -p). PerfCounter.print display the counters exposed by this process -f read and execute commands from the file -l list JVM processes on the local machine -h this help
-
(1) jcmd pid VM.flags 查看某一个进程的JVM启动参数:
- 通过jcmd -l 查看当前所有进程:
- 在通过jcmd 14776 VM.flags
- 通过jcmd -l 查看当前所有进程:
-
(2)jcmd pid help 列出当前运行Java进程可以执行的操作
-
(3)jcmd pid help [JFR.dump]:查看具体命令的选项
-
(4)jcmd pid PerfCounter.print:查看JVM性能相关参数
-
(5)jcmd pid VM.uptime : 查看JVM的启动时长
-
(6)jcmd pid GC.class_histogram :查看系统中类的统计信息
-
(7) jcmd pid Thread.print :查看线程的堆栈信息
-
(8)jcmd pid GC.heap_dump :导出Heap dump 文件,导出的文件可以通过jvisualvm查看:
在利用jvisualvm查看:
-
(9) jcmd pid VM.system_properties :查看JVM的属性信息
-
(10)jcmd pid VM.version:查看目标JVM进程的版本信息
-
(11)jcmd pid VM.command_line :查看JVM启动的命令行参数信息
-
jstack:可以查看或是导出Java应用程序中线程的堆栈信息