JVM tool guide · jvm clijcmd: Send Diagnostic Commands to a Running JVM
jcmd is the most powerful bundled JVM diagnostic tool and the one most developers under-use. Rather than juggling several binaries, jcmd sends a list of diagnostic commands to a running JVM over the Java Attach API: heap dumps, thread dumps, starting/stopping Java Flight Recorder recordings, forcing garbage collection, and reading or flipping flags.
Because it speaks to any attachable local JVM, jcmd has become the natural first stop for 'what is this process doing' questions. Keep jps in your pocket to find PIDs, and jcmd for everything after that.
Official jcmd project
Find processes and list commands
jps maps Java processes to PIDs; ask the target JVM for its supported commands with jcmd help.
# Find Java PIDs
jps -lvv
# What can this JVM do?
jcmd <pid> help
# List attachable JVMs
jcmd -l
Dump the heap
Heap dumps feed Eclipse MAT for leak/dominator analysis. The default includes only live (reachable) objects, which is smaller and usually what you want.
# Live-object heap dump
jcmd <pid> GC.heap_dump /tmp/heap.hprof
# Include unreachable objects too
jcmd <pid> GC.heap_dump -all /tmp/heap-full.hprof
Dump threads
Thread dumps are the raw material for deadlock and hang analysis. Take two dumps a few seconds apart and confirm the same threads are stuck before concluding it is a hang, not a transient wait.
# Thread dump to a file
jcmd <pid> Thread.print -l > threads-$(date +%s).txt
Start / stop a JFR recording
Java Flight Recorder can be started on demand via jcmd even if the JVM was not launched with JFR flags. Let it run for a window, then dump the .jfr file for analysis in JDK Mission Control.
# Record for 60s into a file
jcmd <pid> JFR.start name=diag duration=60s filename=/tmp/diag.jfr
# Status
jcmd <pid> JFR.check
# Dump current recording (keeps recording)
jcmd <pid> JFR.dump name=diag filename=/tmp/diag.jfr
# Stop
jcmd <pid> JFR.stop name=diag filename=/tmp/diag.jfr
Force GC and inspect flags
For testing collector behavior or verifying which flags a process actually runs with, jcmd can explicitly trigger GC and print effective VM flags and properties.
# Request a full GC (diagnostic/benchmark aid only)
jcmd <pid> GC.run
# Effective command-line flags
jcmd <pid> VM.flags
# System properties
jcmd <pid> VM.system_properties
Quick startGet productive in minutes
90-second diagnosis loop
One pass over a live JVM: find it, capture threads, dump heap, start a short JFR recording.
jps -l
jcmd <pid> Thread.print -l > threads.txt
jcmd <pid> GC.heap_dump heap.hprof
jcmd <pid> JFR.start duration=30s filename=diag.jfr
Last updated August 2026 · JVM Tools is independent and not affiliated with Oracle.