Pre-General Availability: 2017-05-24

jcmd

You use the jcmd utility to send diagnostic command requests to a running Java Virtual Machine (JVM).

Synopsis

jcmd [pid | main-class] command...|PerfCounter.print| 
-f filename
jcmd -l
jcmd -h
pid
When used, the jcmd utility sends the diagnostic command request to the process ID for the Java process.
main-class
When used, the jcmd utility sends the diagnostic command request to all Java processes with the specified name of the main class.
command

The command sent to the specified Java process. The command must be a valid jcmd command for the selected JVM. The list of available diagnostic commands for jcmd is obtained by running the help command jcmd pid help where pid is the process id for the running Java process.

Perfcounter.print

Prints the performance counters available for the specified Java process. See Options for the jcmd Command

filename

The name of the file from which to read diagnostic commands and then send them to the specified Java process. This is send only with the -f option. See Options for the jcmd Command.

-l

Prints the list of running Java process identifiers with the main class and command-line arguments that were used to launch the process.

-h

Prints the tool's help message.

Description

The jcmd utility is used to send diagnostic command requests to the JVM. It must be used on the same machine on which the JVM is running, and have the same effective user and group identifiers that were used to launch the JVM. Each diagnostic command has its own set of arguments. To display the description, syntax, and a list of available arguments for a diagnostic command, use the name of the command as the argument:

jcmd pid help command

If arguments contain spaces, then you must surround them with single or double quotation marks (' or "). In addition, you must escape single or double quotation marks with a backslash (\) to prevent the operating system shell from processing quotation marks. Alternatively, you can surround these arguments with single quotation marks and then with double quotation marks (or with double quotation marks and then with single quotation marks).

If you specify the process identifier (pid) or the main class (main-class) as the first argument, then the jcmd utility sends the diagnostic command request to the Java process with the specified identifier or to all Java processes with the specified name of the main class. You can also send the diagnostic command request to all available Java processes by specifying 0 as the process identifier.

If you run jcmd without arguments or with the -l option, it prints the list of running Java process identifiers with the main class and command-line arguments that were used to launch the process. Running jcmd with the -h or -help option prints the tool's help message.

Use one of the following as the diagnostic command request:

  • Perfcounter.print

  • -f filename

  • command [arguments]

Options for the jcmd Command

Options are mutually exclusive.

Perfcounter.print

Prints the performance counters available for the specified Java process. The list of performance counters might vary with the Java process.

-f filename

The name of the file from which to read diagnostic commands and send them to the specified Java process. Used only with the -f option.

Each command in the file must be written on a single line. Lines starting with a number sign (#) are ignored. Processing the file ends either when all lines have been read or when a line containing the stop keyword is read.

-h or —help

Prints a help message.

-l

Prints the list of running Java process identifiers with the main class and command-line arguments.