The jcmd Command

Name

jcmd - 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

Note:

The Java Flight Recorder (JFR) used with the jcmd utility is a commercial product and must be enabled before it is used. Once the JVM is running, the jcmd command VM.unlock_commercial_features is used to unlock commercial features and enable use of the JFR commands described in Commands for jcmd.

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 must be a valid jcmd command for the selected JVM. The list of available commands for jcmd is obtained by running the help command (jcmd pid help) where pid is the process ID for the running Java process. 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, it lists the running Java process identifiers with the main class and command-line arguments that were used to launch the process (the same as using -l).
Perfcounter.print
Prints the performance counters exposed by the specified Java process.
-f filename
Reads and executes commands from a specified file, filename.
-l

Displays the list of Java Virtual Machine process identifiers that are not running in a separate docker process along with the main class and command-line arguments that were used to launch the process. If the JVM is in a docker process, you must use tools such as ps to look up the PID.

Note:

Using jcmd without arguments is the same as using jcmd -l.

-h
Displays thejcmd utility's command-line help.

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. For example:

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.

Commands for jcmd

The command must be a valid jcmd diagnostic command for the selected JVM. The list of available commands for jcmd is obtained by running the help command (jcmd pid help) where pid is the process ID for a running Java process. 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, it lists the running Java process identifiers that are not in separate docker processes along with the main class and command-line arguments that were used to launch the process (the same as using -l).

The following commands are available:

help [options] [arguments]

For more information about a specific command.

arguments:

Note:

The following options must be specified using either key or key=value syntax.

options:

Compiler.codecache

Prints code cache layout and bounds.

Impact: Low

Permission: java.lang.management.ManagementPermission(monitor)

Compiler.codelist

Prints all compiled methods in code cache that are alive.

Impact: Medium

Permission: java.lang.management.ManagementPermission(monitor)

Compiler.queue

Prints methods queued for compilation.

Impact: Low

Permission: java.lang.management.ManagementPermission(monitor)

Compiler.directives_add *filename* *arguments*

Adds compiler directives from a file.

Impact: Low

Permission: java.lang.management.ManagementPermission(monitor)

arguments:

filename: The name of the directives file (STRING, no default value)

Compiler.directives_clear

Remove all compiler directives.

Impact: Low

Permission: java.lang.management.ManagementPermission(monitor)

Compiler.directives_print

Prints all active compiler directives.

Impact: Low

Permission: java.lang.management.ManagementPermission(monitor)

Compiler.directives_remove

Remove latest added compiler directive.

Impact: Low

Permission: java.lang.management.ManagementPermission(monitor)

GC.class_histogram [options]

Provides statistics about the Java heap usage.

Impact: High --- depends on Java heap size and content.

Permission: java.lang.management.ManagementPermission(monitor)

Note:

The options must be specified using either key or key=value syntax.

options:

GC.class_stats [options] [arguments]

Provide statistics about Java class meta data.

Impact: High --- depends on Java heap size and content.

Note:

The options must be specified using either key or key=value syntax.

options:

arguments:

GC.finalizer_info

Provides information about the Java finalization queue.

Impact: Medium

Permission: java.lang.management.ManagementPermission(monitor)

GC.heap_dump [options] [arguments]

Generates a HPROF format dump of the Java heap.

Impact: High --- depends on the Java heap size and content. Request a full GC unless the -all option is specified.

Permission: java.lang.management.ManagementPermission(monitor)

Note:

The following options must be specified using either key or key=value syntax.

options:

arguments:

GC.heap_info

Provides generic Java heap information.

Impact: Medium

Permission: java.lang.management.ManagementPermission(monitor)

GC.run

Calls java.lang.System.gc().

Impact: Medium --- depends on the Java heap size and content.

GC.run_finalization

Calls java.lang.System.runFinalization().

Impact: Medium --- depends on the Java content.

JFR.check [options]
See JFR.check in the Java Flight Recorder Command Reference.
JFR.configure [options]
See JFR.configure in the Java Flight Recorder Command Reference.
JFR.dump [options]
See JFR.dump in the Java Flight Recorder Command Reference.
JFR.start [options]
See JFR.start in the Java Flight Recorder Command Reference.
JFR.stop [options]
See JFR.stop in the Java Flight Recorder Command Reference.
JVMTI.agent_load [arguments]

Loads JVMTI native agent.

Impact: Low

Permission: java.lang.management.ManagementPermission(control)

arguments:

JVMTI.data_dump

Signals the JVM to do a data-dump request for JVMTI.

Impact: High

Permission: java.lang.management.ManagementPermission(monitor)

ManagementAgent.start [options]

Starts remote management agent.

Impact: Low --- no impact

Note:

The following options must be specified using either key or key=value syntax.

options:

ManagementAgent.start_local

Starts the local management agent.

Impact: Low --- no impact

ManagementAgent.status

Print the management agent status.

Impact: Low --- no impact

Permission: java.lang.management.ManagementPermission(monitor)

ManagementAgent.stop

Stops the remote management agent.

Impact: Low --- no impact

Thread.print [options]

Prints all threads with stacktraces.

Impact: Medium --- depends on the number of threads.

Permission: java.lang.management.ManagementPermission(monitor)

Note:

The following options must be specified using either key or key=value syntax.

options:

VM.check_commercial_features

Display status of commercial features

Impact: Low --- no impact

VM.unlock_commercial_features

Unlock commercial features

Impact: Low --- no impact

Permission: java.lang.management.ManagementPermission(control)

VM.classloader_stats

Prints statistics about all ClassLoaders.

Impact: Low

Permission: java.lang.management.ManagementPermission(monitor)

VM.class_hierarchy [options] [arguments]

Prints a list of all loaded classes, indented to show the class hierarchy. The name of each class is followed by the ClassLoaderData* of its ClassLoader, or "null" if it is loaded by the bootstrap class loader.

Impact: Medium --- depends on the number of loaded classes.

Permission: java.lang.management.ManagementPermission(monitor)

Note:

The following options must be specified using either key or key=value syntax.

options:

arguments:

VM.command_line

Prints the command line used to start this VM instance.

Impact: Low

Permission: java.lang.management.ManagementPermission(monitor)

VM.dynlibs

Prints the loaded dynamic libraries.

Impact: Low

Permission: java.lang.management.ManagementPermission(monitor)

VM.info

Prints information about the JVM environment and status.

Impact: Low

Permission: java.lang.management.ManagementPermission(monitor)

VM.log [options]

Lists current log configuration, enables/disables/configures a log output, or ro tates all logs.

Impact: Low

Permission: java.lang.management.ManagementPermission(control)

options:

Note:

The following options must be specified using either key or key=value syntax.

VM.flags [options]

Prints the VM flag options and their current values.

Impact: Low

Permission: java.lang.management.ManagementPermission(monitor)

Note:

The following options must be specified using either key or key=value syntax.

options:

VM.native_memory [options]

Prints native memory usage

Impact: Medium

Permission: java.lang.management.ManagementPermission(monitor)

Note:

The following options must be specified using either key or key=value syntax.

options:

VM.print_touched_methods

Prints all methods that have ever been touched during the lifetime of this JVM.

Impact: Medium --- depends on Java content.

VM.set_flag [arguments]

Sets the VM flag option by using the provided value.

Impact: Low

Permission: java.lang.management.ManagementPermission(control)

arguments:

VM.stringtable [options]

Dumps the string table.

Impact: Medium --- depends on the Java content.

Permission: java.lang.management.ManagementPermission(monitor)

Note:

The following options must be specified using either key or key=value syntax.

options:

VM.symboltable [options]

Dumps the symbol table.

Impact: Medium --- depends on the Java content.

Permission: java.lang.management.ManagementPermission(monitor)

Note:

The following options must be specified using either key or key=value syntax).

options:

VM.systemdictionary

Prints the statistics for dictionary hashtable sizes and bucket length.

Impact: Medium

Permission: java.lang.management.ManagementPermission(monitor)

Note:

The following options must be specified using either key or key=value syntax.

options:

VM.system_properties

Prints the system properties.

Impact: Low

Permission: java.util.PropertyPermission(*, read)

VM.uptime [options]

Prints the VM uptime.

Impact: Low

Note:

The following options must be specified using either key or key=value syntax.

options:

VM.version

Prints JVM version information.

Impact: Low

Permission: java.util.PropertyPermission(java.vm.version, read)