Skip to content

jcmd

jcmd is a utility used to diagnose and monitor Java Virtual Machines (JVMs). 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]

Basic Usage

The tool can be executed in several ways, depending on the target and the desired operation.^[600-developer__operation-maintenance__zabbix__zabbix-key.md]

  • List processes: Running jcmd or jcmd -l displays a list of Java processes running on the local machine.^[600-developer__operation-maintenance__zabbix__zabbix-key.md]
  • Send a command: To interact with a specific JVM, you must provide the Process ID (pid) or the main class name, followed by the command.^[600-developer__operation-maintenance__zabbix__zabbix-key.md]
    • Syntax: jcmd <pid | main class> <command ...|PerfCounter.print|-f file>
  • Print PerfCounters: The PerfCounter.print argument displays the performance counters exposed by the process.^[600-developer__operation-maintenance__zabbix__zabbix-key.md]
  • Batch commands: The -f option allows reading and executing commands from a file.^[600-developer__operation-maintenance__zabbix__zabbix-key.md]
  • Help: Using jcmd -h displays usage help, while jcmd <pid> help lists the specific commands available for that JVM instance.^[600-developer__operation-maintenance__zabbix__zabbix-key.md]

Common Commands

Specific diagnostic commands can be invoked against a target PID.^[600-developer__operation-maintenance__zabbix__zabbix-key.md]

  • VM.command_line: Displays the command line used to start the JVM, including JVM arguments and the Java class path.^[600-developer__operation-maintenance__zabbix__zabbix-key.md]
  • VM.flags: Shows the JVM flag settings.
  • VM.system_properties: Prints the system properties.
  • VM.version: Displays the JVM version string.
  • VM.uptime: Shows the uptime of the JVM.
  • GC.heap_dump: Triggers a heap dump.
  • GC.class_histogram: Prints a class histogram.
  • Thread.print: Prints a thread dump.
  • JFR.start / JFR.stop / JFR.dump: Controls Java Flight Recordings.
  • help: Lists available commands when appended to a specific PID.^[600-developer__operation-maintenance__zabbix__zabbix-key.md]
  • [[jps]]
  • [[jinfo]]
  • [[jstat]]
  • [[JVM]]

Sources

  • 600-developer__operation-maintenance__zabbix__zabbix-key.md