Skip to content

jcmd JVM diagnostic tool

jcmd is a utility used to diagnose and resolve issues with the Java Virtual Machine (JVM). It is available in the JDK and allows users to send diagnostic command requests to a running Java process^[600-developer-operation-maintenance-zabbix-zabbix-key.md].

Usage

The basic syntax for jcmd involves specifying a process ID (pid) or a main class, followed by a command.^[600-developer-operation-maintenance-zabbix-zabbix-key.md]

jcmd <pid | main class> <command ...|PerfCounter.print|-f file>

If no options are provided, the tool lists all Java processes currently running on the local machine^[600-developer-operation-maintenance-zabbix-zabbix-key.md].

Common Flags

  • -l: Lists JVM processes on the local machine^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • -h: Displays help information regarding usage^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • -f: Reads and executes commands from a file^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • PerfCounter.print: Displays the performance counters exposed by the specified process^[600-developer-operation-maintenance-zabbix-zabbix-key.md].

Available Commands

Executing jcmd <pid> help displays the list of valid commands available for the specific JVM instance^[600-developer-operation-maintenance-zabbix-zabbix-key.md]. Common commands include:

  • JFR.start/stop/dump/check: Controls Java Flight Recordings^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • GC.class_histogram: Prints a histogram of class instances^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • GC.heap_dump: Creates a heap dump of the JVM^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • GC.run: Initiates garbage collection^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • Thread.print: Prints thread information^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • VM.uptime: Prints JVM uptime^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • VM.system_properties: Prints Java system properties^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • VM.flags: Prints JVM flag values^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • VM.command_line: Prints the command line used to start the JVM^[600-developer-operation-maintenance-zabbix-zabbix-key.md].
  • [[jinfo]]
  • [[jps]]
  • [[JVM]]

Sources

^[600-developer-operation-maintenance-zabbix-zabbix-key.md]