Apr 9, 2018

jcmd - a utility to send diagnostic command requests to a Java Virtual Machine supporting this feature.

Used without arguments or with the -l option, jcmd prints the list of running Java processes with their process ID, their main class and their command-line arguments.
When a process ID is specified on the command line, jcmd sends the diagnostic command request to the process with this ID.
When a main class is specified on the command line, jcmd sends the diagnostic command request to all Java processes for which the command-line argument is a substring of the Java process' main class.
With the PerfCounter.print argument, jcmd prints the performance counters available on the targeted Java processes.
With the -f option, jcmd sends to the targeted Java processes the diagnostic commands stored in the specified file.
Example usage:
jcmd -l
4896 jdk.nashorn.tools.Shell
8102 sun.tools.jcmd.JCmd -l
23610 com.sun.enterprise.glassfish.bootstrap.ASMain --domain domain1 --domaindir /d/glassfish-3.1.2.2/glassfish/domains/domain1

-h
Prints a help message.
-help
Prints a help message.
To find out what kind of information jcmd can display about a JVM, pass the pid along with help to the command. For example:

jcmd 23610 help
23610:
The following commands are available:
VM.native_memory
VM.commercial_features
ManagementAgent.stop
ManagementAgent.start_local
ManagementAgent.start
Thread.print
GC.class_histogram
GC.heap_dump
GC.run_finalization
GC.run
VM.uptime
VM.flags
VM.system_properties
VM.command_line
VM.version
help


For more information about a specific command use 'help <command>'.
for example:
jcmd 4636 help Thread.print
jcmd 23610  PerfCounter.print

jcmd 23610 VM.system_properties
23610:
#Fri Aug 22 16:54:43 EDT 2014
java.vendor=Oracle Corporation
com.sun.aas.imqBin=/d/glassfish-3.1.2.2/mq/bin

sun.java.launcher=SUN_STANDARD

jcmd is a way to control the Java Flight Recorder from the command line, which is quite useful when you can't access the machine that is running the JVM of interest from Oracle Java Mission Control and you only have access to a shell.

In one command-line tool, jcmd brings together the functionality of several command-line JDK tools. This post has demonstrated several of the functions provided by jcmd.

See also:

How to take a Thread Dump from a JVM