Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

Java Tools that help you learn how Java works and understand it even more.

JavaFAQ Home » Java Tools Go to all tips in Java Tools


Bookmark and Share

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 permissions.

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:

myServer$jps
13703 AlexMain
9523 Jps
7596 Bootstrap

Here you can see three two applications run: AlexMain and Bootstrap. Third application is our command jps Smile. 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:

myServer$jps -q
13703
9803
7596

Sometimes it is good to know what are arguments were passed to every application. Run jps -m:

myServer$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:
-v

Output the arguments passed to the JVM.
-V

Output the arguments passed to the JVM through the flags file (the .hotspotrc file or the file specified by the -XX:Flags=<filename> argument).

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  Printer Friendly Page
 Send to a Friend  Send to a Friend

.. Bookmark and Share

Search here again if you need more info!
Custom Search



Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

RSS feed Java FAQ RSS feed Java FAQ News     

    RSS feed Java Forums RSS feed Java Forums

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

Interactive software released under GNU GPL, Code Credits, Privacy Policy