Java Tool Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 5.11

Listing JVM Processes on the Local Machine with "jps"

This section provides a tutorial example on how to list all JVM processes on the local machine with process IDs, and other JVM information.

It is very easy to listing JVM processes on the local machine using the "jps" tool. Here is what I did:

1. Run the PrimeNumberSeeker.java program I wrote in another tutorial in a command window:

C:\herong>\Progra~1\java\jdk1.6.0_02\bin\javac PrimeNumberSeeker.java

C:\herong>\Progra~1\java\jdk1.6.0_02\bin\java PrimeNumberSeeker 10 200

Period, Current int, # primes
1, 2, 0
2, 12, 5
3, 21, 8
...

2. While PrimeNumberSeeker.java is running to search for prime numbers, run the "jps" tool in another command window:

C:\herong>\Progra~1\java\jdk1.6.0_02\bin\jps -l -m -v

2836 PrimeNumberSeeker 10 200
3812 sun.tools.jps.Jps -l -m -v 
   -Dapplication.home=C:\Program Files\java\jdk1.6.0_02 -Xms8m

Several interesting notes on the "jps" output:

  • Each JVM process is represented by starting class running in side the JVM.
  • The number displayed before the class name is the process ID.
  • When you run "jps", it starts a JVM process, which is also listed in the "jps" output.
  • The package name, "sun.tools.jps", is displayed because of the "-l" option.
  • The arguments passed to the main method, "10 200", are displayed because of the "-m" option.
  • The parameters passed to the JVM, "-D... -X...", are displayed because of the "-v" option.

Sections in This Chapter

'jps' - JVM Process Status Tool

Listing JVM Processes on the Local Machine with "jps"

'jstatd' - JVM Remote Monitoring Server

Starting 'jstatd' with a Security Policy File

Connecting to 'jps' to Remote 'jstatd'

'jstat' Command Options and Parameters

Garbage Collection Testing Program

'jstat -gcutil' - Garbage Collection Statistics

Accessing Remote JVM Processes with 'jstat'

Dr. Herong Yang, updated in 2008
Listing JVM Processes on the Local Machine with "jps"