jcmd: One JDK Command-Line Tool to Rule Them All

The jcmd tool was introduced with Oracle’s Java 7 and is particularly useful in troubleshooting issues with JVM applications by using it to identify Java processes’ IDs (akin to jps), acquiring heap dumps (akin to jmap), acquiring thread dumps (akin to jstack), viewing virtual machine characteristics such as system properties and command-line flags (akin to jinfo), and acquiring garbage collection statistics (akin to jstat).

Running jcmd without arguments will return all Java processes running in the system along with their PIDs

jcmd PID help will list all commands supported for that particular Java process

jcmd PID VM.flags will return JVM flags set for the process. Commands are case sensitive. jcmd vm.flags will not work

jcmd PID Thread.print will print the thread dump

jcmd PID GC.run will run the garbage collector

jcmd PID GC.heap_dump filename will store the heat dump

There are many more commands which you can play with

Uday Ogra

Connect with me at http://facebook.com/tendulkarogra and lets have some healthy discussion :)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *