Check Java processes on Linux with the jps command

With many processes running on a system, it's useful to have a quick way to identify only Java with the jps command.
30 readers like this.
Coffee beans

Pixabay. CC0.

On Linux, there are commands to view processes running on your system. A process is any ongoing event being managed by the kernel. A process is spawned when you launch an application, but there are also many other processes running in the background of your computer, including programs to keep your system time accurate, to monitor for new filesystems, to index files, and more. The utilities, such as those included in the procps-ng package, that monitor these processes tend to be intentionally generic. They look at all processes on your computer so you can filter the list based on what you need to know.

On Linux, you can view processes with the ps command. It is the simplest way to view the running processes on your system.

$ ps
    PID TTY          TIME CMD
   4486 pts/0    00:00:00 bash
  66930 pts/0    00:00:00 ps

You can use the ps command to view running Java processes on a system also by piping output to grep.

$ ps ax |grep java
  67604 pts/1    Sl+    0:18 /usr/lib/jvm/java-11-openjdk-11.0.12.0.7-4.fc34.x86_64/bin/java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED --add-opens=java.naming/javax.naming=ALL-UNNAMED -Dorg.jboss.boot.log.file=/home/alan/wildfly/24.0.1/standalone/log/server.log -Dlogging.configuration=file:/home/alan/wildfly/24.0.1/standalone/configuration/logging.properties -jar /home/alan/wildfly/24.0.1/jboss-modules.jar -mp /home/alan/wildfly/24.0.1/modules org.jboss.as.standalone -Djboss.home.dir=/home/alan/wildfly/24.0.1 -Djboss.server.base.dir=/home/alan/wildfly/24.0.1/standalone

OpenJDK, however, has its very own specific process monitor. The Java Virtual Machine Process Status (jps) tool allows you to scan for each running instance of the Java Virtual Machine (JVM) on your system.

To view a similar output as seen in the ps command, use the -v option. This is useful, partly because it requires less typing.

$ jps -v
67604 jboss-modules.jar -D[Standalone] -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.management/javax.management=ALL-UNNAMED --add-opens=java.naming/javax.naming=ALL-UNNAMED -Dorg.jboss.boot.log.file=/home/alan/wildfly/24.0.1/standalone/log/server.log -Dlogging.configuration=file:/home/alan/wildfly/24.0.1/standalone/configuration/logging.properties

The default jps output provides the process identifier and the class name or Jar file name of each detected instance.

$ jps
67604 jboss-modules.jar
69430 Jps

Note: The man page for jps states that it is experimental and unsupported. Still, it's a nice-to-have option because often many processes are running on a system, and having a quick way to identify only Java is useful.

Because Java is still a popular language today, being familiar with the Java Development Kit and Runtime Environment remains important. They contain many tools applicable to the development and maintenance of Java applications.

What to read next
Tags
Alan Formy-Duval Opensource.com Correspondent
Alan has 20 years of IT experience, mostly in the Government and Financial sectors. He started as a Value Added Reseller before moving into Systems Engineering. Alan's background is in high-availability clustered apps. He wrote the 'Users and Groups' and 'Apache and the Web Stack' chapters in the Oracle Press/McGraw Hill 'Oracle Solaris 11 System Administration' book.

1 Comment

It's funny, we have something similar we use to monitor our java microservices, output looks like... big difference for us is the inclusion of the port that the service is listening on.

# java-services.sh status
java-services are running.
374834 2021-10-05T17:15:02 8088 corp-customerweb-service-1.0.0-99|-Xmx2048m -Dspring.profiles.active=pr
447436 2021-10-05T17:15:03 8093 corp-warehousefilesweep-service-1.0.0-113|-Xmx2048m -Dspring.profiles.active=pr
537524 2021-10-05T17:15:03 8085 corp-housingrequest-service-1.0.0-185|-Xmx2048m -Dspring.profiles.active=pr
629720 2021-10-05T17:15:03 8100 corp-stdutil-service-1.0.0-229|-Xmx2048m -Dspring.profiles.active=pr
897432 2021-10-05T17:15:02 8095 corp-email-service-1.0.0-226|-Xmx2048m -Dspring.profiles.active=pr
981411 2021-10-05T17:15:02 8089 corp-directweb-service-1.0.0-190|-Xmx2048m -Dspring.profiles.active=pr
1122942 2021-10-05T17:15:02 8098 corp-exchange-service-1.0.0-197|-Xmx2048m -Dspring.profiles.active=pr
1531509 2021-10-05T17:15:02 8097 corp-document-service-1.0.0-33|-Xmx2048m -Dspring.profiles.active=pr
1553248 2021-10-05T17:15:02 8090 corp-cms-service-1.0.0-35|-Xmx2048m -Dspring.profiles.active=pr
1574057 2021-10-05T17:15:02 8091 corp-customerweblog-service-1.0.0-37|-Xmx2048m -Dspring.profiles.active=pr
1691363 2021-10-05T17:15:02 8086 corp-housingresponse-service-1.0.0-48|-Xmx2048m -Dspring.profiles.active=pr
1849529 2021-10-05T17:15:02 8083 corp-applookup-service-1.0.0-32|-Xmx2048m -Dspring.profiles.active=pr
2112741 2021-10-05T21:51:17 8087 corp-deploy-service-1.0.0-202|-Xmx2048m -Dspring.profiles.active=pr
2130221 2021-10-05T17:15:02 8096 corp-voip-service-1.0.0-143|-Xmx2048m -Dspring.profiles.active=pr
2714837 2021-10-05T17:15:02 8103 corp-ivr-service-1.2.0-86|-Xmx2048m -Dspring.profiles.active=pr
2925976 2021-10-05T17:15:02 8082 corp-facebook-service-1.0.0-237|-Xmx2048m -Dspring.profiles.active=pr
3098356 2021-10-06T09:38:20 8081 corp-azure-service-1.0.0-262|-Xmx2048m -Dspring.profiles.active=pr
3122901 2021-10-05T17:15:02 8092 corp-warehousedbsync-service-1.0.0-253|-Xmx2048m -Dspring.profiles.active=pr
3163783 2021-10-05T17:15:02 8101 corp-four11-service-1.0.0-78|-Xmx2048m -Dspring.profiles.active=pr
3332200 2021-10-06T12:25:18 8094 corp-websitedbsync-service-1.0.0-245|-Xmx8048m -Dspring.profiles.active=pr
3361733 2021-10-05T17:15:03 8099 corp-websitefilesweep-service-1.0.0-52|-Xmx2048m -Dspring.profiles.active=pr
3991842 2021-10-05T17:15:02 8102 corp-orig-service-1.0.0-41|-Xmx2048m -Dspring.profiles.active=pr

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.