// shall I write some keywords here to boost search engine ranking?

Sunday, July 13, 2008

Get PID of Java program in Windows

In Linux, we can use ps to get process status of all process, include running Java program.

However, in Windows no matter using Task Manager or tasklist command, we can only see our running Java program as java.exe. So you cant differentiate them if you have multiple Java program running in same server.

And the good news is, we can now use a new command jps that bundle with JDK 1.6 to get the PID and main class/JAR file of running Java process.

For example, I start running Tomcat and ActiveMQ on my laptop, and with command jps -l, below is the output:

5280 C:\apache-activemq-5.0.0\bin\../bin/run.jar
1824 org.apache.catalina.startup.Bootstrap
2652 sun.tools.jps.Jps
By the way, Sun still mark jps as "experimental" status. For more information of jps, you may check it out here.

No comments: