Overview
jps is ps for JVMs: it lists the Java processes visible to the current user with their pids
and main class, and is usually the first command in any JVM diagnostic session — you need a pid
before jcmd, jstack or jstat can do anything. Bare jcmd now does the same listing, but
jps flags give more control over what is shown.
Key points
- Default output: pid + short main class name (or jar name for
java -jarlaunches). -l: full package name of the main class, or full path to the jar.-m: arguments passed tomain().-v: JVM arguments (-Xmx,-D...flags) — quick way to check what heap a process was really given.-q: pids only, handy for scripting.- Perfdata mechanism: each HotSpot JVM exports instrumentation counters into a
memory-mapped file
/tmp/hsperfdata_<user>/<pid>(unless-XX:-UsePerfData). jps discovers JVMs by scanning these files and reads its data from them — no attach needed. - Consequences: you only see JVMs of users whose perfdata dirs you can read (in practice:
your own, or all as root); wiping
/tmpor setting-XX:PerfDisableSharedMemmakes processes invisible to jps/jstat; containers isolate/tmp, so jps inside the container ornsenteris needed for containerised JVMs. - Remote mode is dead: the old
jps <host>viajstatdis effectively obsolete; use proper observability for remote hosts.
Examples
jps -lv
# 4242 com.example.app.Main -Xmx2g -Dspring.profiles.active=prod
# 5150 org.gradle.launcher.daemon.bootstrap.GradleDaemon -Xmx1g
Related
- JDK & tools — parent catalogue of the JDK toolchain.
- jcmd — bare
jcmdlists JVMs too, then takes the pid you found. - jstat — reads the same perfdata counters, continuously.
- jstack — typical next step once you have the pid.