LinuxCommandLibrary

jps

List Java Virtual Machine process information

TLDR

List all JVM processes

$ jps
copy

List all JVM processes with only PID
$ jps -q
copy

Display the arguments passed to the processes
$ jps -m
copy

Display the full package name of all processes
$ jps -l
copy

Display the arguments passed to the JVM
$ jps -v
copy

SYNOPSIS

jps [options] [hostid]

PARAMETERS

-q
    Suppresses the output of the class name, JAR file name, and arguments passed to the main method. Only the LVMID is displayed.

-m
    Outputs the arguments passed to the main method. This can be useful for identifying different instances of the same application or for quickly seeing startup parameters.

-l
    Outputs the full package name for the application's main class or the full path name to the application's JAR file. This helps in distinguishing between different versions or installations of an application.

-v
    Outputs the arguments passed to the JVM itself. This includes options like heap size settings (e.g., -Xmx), garbage collector settings, and other JVM-specific flags, which are crucial for diagnostics.

hostid
    Specifies the remote host to list JVMs on. For this to work, the jstatd daemon must be running on the remote host and configured correctly for remote monitoring. If omitted, jps lists JVMs on the local machine.

DESCRIPTION

The jps (Java Virtual Machine Process Status Tool) is a command-line utility included with the Java Development Kit (JDK). It serves to list the instrumented HotSpot Java Virtual Machines (JVMs) currently running on the target system.

For each detected JVM, jps typically displays the JVM's local VM identifier (LVMID), which is usually the process ID (PID) of the Java process, along with the name of the main class or JAR file. This tool is invaluable for developers and system administrators as it provides a quick and efficient way to identify and monitor running Java applications. It is frequently used during debugging, performance troubleshooting, and general system management to quickly locate specific Java processes without sifting through generic process lists.

CAVEATS

jps primarily lists HotSpot JVMs; other JVM implementations might not be detected. It requires a JDK/JRE installation to be present on the system. Security policies and user permissions can restrict visibility; by default, jps only lists JVMs running under the same user ID. To see all JVMs, it often needs to be run as a privileged user (e.g., root). Remote monitoring using hostid depends on the jstatd daemon running on the target system.

<I>SECURITY CONSIDERATIONS</I>

By default, jps only displays JVMs that belong to the user executing the command. To list JVMs belonging to other users or system-wide JVMs, jps must be executed with appropriate privileges, such as by the root user. However, even with root privileges, JVMs can be configured to restrict attach permissions via security policies (e.g., management.properties or the sun.jvm.hotspot.tools.jps.disable system property), potentially preventing their listing.

<I>HOW IT WORKS</I>

jps identifies running HotSpot JVMs by scanning for temporary files created in the JVM's working directory or specific system directories (like /tmp/hsperfdata_ on Linux/Unix). These files contain information about the running JVM, including its PID and unique identifier. It relies on the JVM having the 'attach mechanism' enabled, which is standard for HotSpot JVMs by default unless explicitly disabled for security reasons.

HISTORY

The jps command was introduced with JDK 5 (1.5.0) as part of a new set of monitoring and management tools for the Java platform. Before its introduction, identifying specific Java processes often involved manually parsing the output of generic process listing commands like ps for Java-related keywords. jps streamlined this process by providing a dedicated, Java-aware utility, making it a cornerstone for Java diagnostics and troubleshooting.

SEE ALSO

ps(1), top(1), jstack(1), jstat(1), jmap(1), jcmd(1)

Copied to clipboard