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
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
jcmd
utility sends the diagnostic command request to the process ID for the Java process.main-class
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 running Java Virtual Machine process identifiers with the main class and command-line arguments that were used to launch the process.
-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.
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]
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 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
).
The following commands are available:
help [options][arguments]
For more information about a specific command.
arguments
:
command name : The name of the command for which we want help (STRING, no default value)
Note:
The following options
must be specified using either key
or key=value
syntax.
options
:
—all
: (Optional) Show help for all commands (BOOLEAN, false) .
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
:
-all
: (Optional) Inspects all objects, including unreachable objects (BOOLEAN, false)
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
:
-all
: (Optional) Shows all columns (BOOLEAN, false)
-csv
: (Optional) Prints in CSV (comma-separated values) format for spreadsheets (BOOLEAN, false)
-help
: (Optional) Shows the meaning of all the columns (BOOLEAN, false)
arguments
InstBytes
KlassBytes
CpAll
annotations
MethodCount
Bytecodes
MethodAll
ROAll
RWAll
Total
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
:
-all
: [optional] Dump all objects, including unreachable objects (BOOLE AN, false)
arguments
:
filename: The name of the dump file (STRING, no default value)
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]
Checks running JFR recording(s).
Impact: Low
Permission: java.lang.management.ManagementPermission(monitor)
Note:
The following options
must be specified using either key
or key=value
syntax.
options
:
name
: (Optional) Recording text, e.g. \"My Recording\" or omit to see all recordings (STRING, no default value)
verbose
: (Optional) Print event settings for the recording(s) (BOOLEAN, false)
JFR.configure [options]
Configures the Java Flight Recorder (JFR)
Impact: Low
Permission: java.lang.management.ManagementPermission(monitor)
Note:
The following options
must be specified using either key
or key=value
syntax.
options
:
repositorypath
: (Optional) Sets the path to the repository, such as
\My Repository\
(STRING, no default value)
dumppath
: (Optional) Sets the path to dump, such as,
\"My Dump path\"
(STRING, no default value)
stackdepth
: (Optional) Sets the stack Depth (JLONG, 64)
globalbuffercount
: (Optional) Sets the number of global buffers, (JLONG, 32)
globalbuffersize
: (Optional) Sets the size of a global buffers, (JLONG, 524288)
thread_buffer_size
: (Optional) Sets the size of a thread buffer (JLONG, 8192)
memorysize
: (Optional) Sets the overall memory size, (JLONG, 16777216)
threadbufferstodisk
: (Optional) Sets the thread buffers to be written directly to disk (BOOLEAN, false)
maxchunksize
: (Optional) Sets the size of an individual disk chunk (JLONG, 12582 912)
samplethreads
: (Optional) Activates thread sampling (BOOLEAN, true)
JFR.dump [options]
Copies contents of a JFR recording to file. Either the name or the recording id must be specified.
Impact: Low
Permission: java.lang.management.ManagementPermission(monitor)
Note:
The following options
must be specified using either key
or key=value
syntax.
options
:
name
: (Optional) Recording name, e.g. \"My Recording\" (STRING, no default value)
filename
: Copy recording data to file, i.e \"C:\Users\user\My Recording.jfr\" (STRING, no default value)
path-to-gc-roots
: (Optional) Collects path to GC roots (BOOLEAN, false)
JFR.start [options]
Starts a new JFR recording.
Impact: Medium: Depending on the settings for a recording, the impact can range from low to high.
Permission: java.lang.management.ManagementPermission(monitor)
Note:
The following options
must be specified using either key
or key=value
syntax.
options
:
name
: (Optional) Name that can be used to identify recording, e.g. \"My Recording\" (STRING, no default value)
settings
: (Optional) Settings file(s), e.g. profile or default. See JRE _HOME/lib/jfr (STRING SET, no default value)
delay
: (Optional) Delay recording start with (s)econds, (m)inutes), (h) ours), or (d)ays, e.g. 5h. (NANOTIME, 0)
duration
: (Optional) Duration of recording in (s)econds, (m)inutes, (h) ours, or (d)ays, e.g. 300s. (NANOTIME, 0)
disk
: (Optional) Recording should be persisted to disk (BOOLEAN, no def ault value)
filename
: (Optional) Resulting recording filename, e.g. \"C:\Users\user \My Recording.jfr\" (STRING, no default value)
maxage
: (Optional) Maximum time to keep recorded data (on disk) in (s)e conds, (m)inutes, (h)ours, or (d)ays, e.g. 60m, or 0 for no limit (NANOTIME, 0)
maxsize
: (Optional) Maximum amount of bytes to keep (on disk) in (k)B, (M)B or (G)B, e.g. 500M, or 0 for no limit (MEMORY SIZE, 0)
dumponexit
: (Optional) Dump running recording when JVM shuts down (BOOL EAN, no default value)
path-to-gc-roots
: (Optional) Collects path to GC roots (BOOLEAN, false)
JFR.stop [options]
Stops a JFR recording
Impact: Low
Permission: java.lang.management.ManagementPermission(monitor)
Note:
The following options
must be specified using either key
or key=value
syntax.
options
:
name
: (Optional) Recording text, such as,
\"My Recording\"
(STRING, no default value)
filename
: (Optional) Copy recording data to file, such as,
. \"C:\Users\user\ My Recording.jfr\"
(STRING, no default value)
JVMTI.agent_load [arguments]
Loads JVMTI native agent.
Impact: Low
Permission: java.lang.management.ManagementPermission(control)
arguments
:
library path : Absolute path of the JVMTI agent to load. (STRING, no default value)
agent option : (Optional) Option string to pass the agent. (STRING, no default value)
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
:
config.file
: (Optional) Sets com.sun.management.config.file
(STRING, no default value)
jmxremote.host
: (Optional) Sets com.sun.management.jmxremote.host
(STRIN G, no default value)
jmxremote.port
: (Optional) Sets com.sun.management.jmxremote.port
(STRIN G, no default value)
jmxremote.rmi.port
: (Optional) Sets com.sun.management.jmxremote.rmi.port
(STRING, no default value)
jmxremote.ssl
: (Optional) Sets com.sun.management.jmxremote.ssl
(STRING, no default value)
jmxremote.registry.ssl
: (Optional) Sets com.sun.management.jmxremote.registry.ssl
(STRING, no default value)
jmxremote.authenticate
: (Optional) Sets com.sun.management.jmxremote.authenticate
(STRING, no default value)
jmxremote.password.file : (Optional) Sets com.sun.management.jmxremote.password.file
(STRING, no default value)
jmxremote.access.file
: (Optional) Sets com.sun.management.jmxremote.acce ss.file
(STRING, no default value)
jmxremote.login.config
: (Optional) Sets com.sun.management.jmxremote.log in.config
(STRING, no default value)
jmxremote.ssl.enabled.cipher.suites
: (Optional) Sets com.sun.management
.
jmxremote.ssl.enabled.cipher.suite
: (STRING, no default value)
jmxremote.ssl.enabled.protocols
: (Optional) Sets com.sun.management.jmxr emote.ssl.enabled.protocols
(STRING, no default value)
jmxremote.ssl.need.client.auth
: (Optional) Sets com.sun.management.jmxre mote.need.client.auth
(STRING, no default value)
jmxremote.ssl.config.file
: (Optional) Sets com.sun.management.jmxremote. ssl_config_file
(STRING, no default value)
jmxremote.autodiscovery
: (Optional) Sets com.sun.management.jmxremote.au todiscovery
(STRING, no default value)
jdp.port
: (Optional) Sets com.sun.management.jdp.port
(INT, no default v alue)
jdp.address
: (Optional) Sets com.sun.management.jdp.address
(STRING, no default value)
jdp.source_addr
: (Optional) Sets com.sun.management.jdp.source_addr
(STR ING, no default value)
jdp.ttl
: (Optional) Sets com.sun.management.jdp.ttl
(INT, no default value)
jdp.pause
: (Optional) Sets com.sun.management.jdp.pause
(INT, no default value)
jdp.name
: (Optional) Sets com.sun.management.jdp.name
(STRING, no defaul t value)
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
:
-l
: (Optional) Prints java.util.concurrent
locks (BOOLEAN, false)
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
:
-i
: (Optional) Inherited interfaces should be printed. (BOOLEAN, false)
-s
: (Optional) If a class name is specified, it prints the subclasses. If the class name is not specified, only the superclasses are printed. (BOOLEAN, false)
arguments
classname: (Optional) The name of the class whose hierarchy should be printed. If not specified, all class hierarchies are printed. (STRING, no default value)
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.
output
: (Optional) The name or index (#) of output to configure. (STRING, no default value)
output_options
: (Optional) Options for the output. (STRING, no default value)
what
: (Optional) Configures what tags to log. (STRING, no default value )
decorators
: (Optional) Configures which decorators to use. Use 'none' o r an empty value to remove all. (STRING, no default value)
disable
: (Optional) Turns off all logging and clears the log configurat ion. (BOOLEAN, no default value)
list
: (Optional) Lists current log configuration. (BOOLEAN, no default value)
rotate
: (Optional) Rotates all logs. (BOOLEAN, no default value)
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
:
-all
: (Optional) Prints all flags supported by the VM (BOOLEAN, false).
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
:
summary
: (Optional) Requests runtime to report current memory summary, which includes total reserved and committed memory, along with memory usage summary by each subsystem. (BOOLEAN, false)
detail
: (Optional) Requests runtime to report memory allocation >= 1K by each callsite. (BOOLEAN, false)
baseline
: (Optional) Requests runtime to baseline current memory usage, so it can be compared against in later time. (BOOLEAN, false)
summary.diff
: (Optional) Requests runtime to report memory summary comparison against previous baseline. (BOOLEAN, false)
detail.diff
: (Optional) Requests runtime to report memory detail comparison against previous baseline, which shows the memory allocation activities at different callsites. (BOOLEAN, false)
shutdown
: (Optional) Requests runtime to shutdown itself and free the memory used by runtime. (BOOLEAN, false)
statistics
: (Optional) Prints tracker statistics for tuning purpose. (BOOLEAN, false)
scale
: (Optional) Memory usage in which scale, KB, MB or GB (STRING, KB )
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
:
flag name : The name of the flag that you want to set (STRING, no default value)
string value : (Optional) The value that you want to set (STRING, no default value)
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
:
-verbose
: (Optional) Dumps the content of each string in the table (BOOLEAN, false)
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
:
-verbose
: (Optional) Dumps the content of each symbol in the table (BOOLEAN, false)
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
:
verbose
: (Optional) Dump the content of each dictionary entry for all class loaders (BOOLEAN, false) .
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
:
-date
: (Optional) Adds a prefix with the current date (BOOLEAN, false)
VM.version
Prints JVM version information.
Impact: Low
Permission: java.util.PropertyPermission(java.vm.version, read)