Home

jcmd

jcmd is a command-line tool included with the Java Development Kit (JDK) that allows users to send diagnostic commands to a running Java Virtual Machine (JVM). It communicates via the Attach API and is designed to assist in diagnosing performance, memory, threading, and other VM state issues. The tool targets a specific JVM, typically identified by its process identifier (PID), and executes commands through that target.

jcmd consolidates functionality from several older tools, providing a unified interface for operating on a JVM.

Common usage and commands include: jcmd <pid> help to list available commands for the target JVM; jcmd

Availability and context: jcmd is included in Oracle JDK and OpenJDK distributions from Java 7 onward and

It
can
work
with
a
locally
running
process
and,
in
some
configurations,
can
connect
to
remote
targets
as
well.
Users
invoke
jcmd
with
the
syntax:
jcmd
<pid>
<command>
[arguments].
<pid>
GC.run
to
trigger
a
garbage
collection;
jcmd
<pid>
GC.class_histogram
to
produce
a
histogram
of
loaded
classes;
jcmd
<pid>
GC.heap_dump
/path/file.hprof
to
dump
the
heap;
jcmd
<pid>
Thread.print
to
print
thread
stacks;
and
JFR-related
commands
such
as
JFR.start,
JFR.stop,
or
JFR.dump
on
newer
JDKs.
The
exact
command
set
varies
by
JDK
version,
and
some
commands
may
require
appropriate
permissions
or
specific
product
editions.
is
located
in
the
JDK’s
bin
directory.
It
is
a
widely
used
tool
for
obtaining
runtime
diagnostics,
gathering
data
for
performance
tuning,
and
producing
diagnostic
artifacts.
As
with
any
administrative
tool,
access
should
be
restricted
to
authorized
users.