Java Tools Tutorials - Herong's Tutorial Notes - Version 5.32, by Dr. Herong Yang
Connecting to 'jps' to Remote 'jstatd'
This section provides a tutorial on how to run 'jps' to connect to a remote 'jstatd' server with a RMI URL to list all JVM processes on the remote machine.
With the "jstatd" server running on my local machine as described in the previous section, now I am ready to test how to connect to this "jstatd" server with the "jps" command from a remote machine to list JVM processes.
1. Run my test Java program PrimeNumberSeeker.java in another command window on my local machine:
C:\herong>\Progra~1\java\jdk1.8.0\bin\java PrimeNumberSeeker 10 200 Period, Current int, # primes 1, 2, 0 2, 10, 4 ...
2. Run the "jps" command to connect to the "jstatd" server with the "rmi://localhost" URL as the host identifier:
C:\herong>\Progra~1\java\jdk1.8.0\bin\jps -l -m -v rmi://localhost RMI Registry not available at localhost:1099 Connection refused to host: localhost; nested exception is: java.net.ConnectException: Connection refused: connect
3. The cause of the error is obvious, the "jstatd" server started the internal RMI registry at the port 1234, not the default port 1099. So Run the "jps" command again with the "rmi://localhost:1234":
C:\herong>\Progra~1\java\jdk1.8.0\bin\jps -l -m -v rmi://localhost:1234 3056 sun.tools.jstatd.Jstatd -p 1234 -Dapplication.home=C:\jdk -Xms8m -Djava.security.policy=tools.policy 4080 sun.tools.jps.Jps -l -m -v rmi://localhost:1234 -Dapplication.home=C:\Program Files\java\jdk1.8.0 -Xms8m 2024 PrimeNumberSeeker 10 200
Cool. The "jps" successfully connected to the RMI registry through the "jstatd" server. The output shows correctly all running JVM processes.
Last update: 2015.
Table of Contents