Listing Only Java Processes

Ever do something like the following?

ps aux | grep 'java'

Pretty annoying, especially considering that the output usually shows the enormous startup script commands running with Java. Wouldn’t it be nice if you could just run a command that would list only java processes, and specifically list what the actual application running within the VM is?

As I learned at a JUG last night, there IS a program that will do this. It’s called ‘jps‘.

JPS will list only the java processes running, with their actual PIDs and the shortened names of the entry classnames or jar files. This lets you handily see what is actually running:

jps
18027 Java2Demo.JAR
18032 jps
18005 jstat

Where can you get this amazing tool? You already have it! It’s part of the JDK, apparently. Go to a terminal and type ‘jps’ and check it out.

The program also takes options to list full classnames and it can even connect to a remote machine and list JVMs remotely.

How did I not know about this? It rocks my face off.


One Comment

  1. Bryan:

    Nice tip. I’m with you - how did I not know about this thing. I can think of something that would make it rock more than it already does. If the java process it lists for you is also associated with a port that is being used on your system, show me that port number too, because dam it, I want to be able to kill the PID responsible for the PortAlreadyBeingUsedException or whatever it’s called.

Leave a comment