JavaFAQ Home » Java Tools
Question: I have a few Java applications
and tools which continuously run on our server. We are going to write some
"killer application" script which will kill our application if it hangs. How do
we find pid of that application, which we are going to kill to?
Answer: You can use jps
command which is a part HotSpot JVM instrumentation. Be aware that this tool is
limited to reporting information on JVMs for which it has the access
If you run simply jps without any argument you will report all Java
applications together with lvmid - local VM identifier, which are
usually but not necessarily are the same as pids.
Below you see my example which I run on myServer machine:
Here you can see three two applications run: AlexMain and Bootstrap. Third
application is our command jps . It listed itself.
If you want to get only lvmids you can run the command with -q option which
will suppress the name of application and just give you lvmids:
Sometimes it is good to know what are arguments were passed to every
application. Run jps -m:
13703 AlexMain 25 /home/alex/reserv/client.xml start
9807 Jps -m
7596 Bootstrap start
Here you can see that AlexMain got three input parameters: "25",
"/home/alex/reserv/client.xml" and "start".
Two more parameters you can try yourself, it will help you to learn Java more
and train your habits to do more things by hand.
I will give you just description:
Output the arguments passed to the JVM.
Output the arguments passed to the JVM through the flags file (the .hotspotrc
file or the file specified by the -XX:Flags=<filename>
Additionally to default options, you can pass more options to the underlying
VM executing applications written in Java with -J option.
For example, -J-Xms32m sets the start up
memory to 32 megabytes.
Printer Friendly Page
Send to a Friend
Search here again if you need more info!