troubleshooting Question

Set the process title for java app in Linux

Avatar of drcheap
drcheapFlag for United States of America asked on
Java
4 Comments2 Solutions1281 ViewsLast Modified:
So I start up a java application in Linux, and get something like this from `pstree`:

     |-java---java---5*[java]

Which is all fine until I start up a bunch of apps...

     |-java---java---5*[java]
     |-java---java---3*[java]
     |-java---java---2*[java]
     |-java---java---5*[java]
     |-java---java---7*[java]
     |-java---java---4*[java]

Now I want to know if a certain app is running, or maybe kill a misbehaving one...not so clear which is which.  Yeah, I could use `ps aux | grep ...` and I might be able to narrow down a process which belongs to that app and go from there.  However even that is a mess with a ton of lines like:

javauser 25635  0.1  2.5 1802196 52688 pts/2   Sl   11:16   0:03 java -server -Xms16m -Xmx16m -Djava.security.policy=/blah/ -Djava.endorsed.dirs=/blah -Dnet.jxta.tls.principal=blah -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -cp [insert MASSIVE classpath here] /blah/blah.jar com.class.name.Here Param Param Param


I know in C it's an easy call to setproctitle(...); to set the process name that is displayed.  In fact some apps, like Sendmail, use this to provide a quick status display & activity for each child process -- very handy.  I realize that not all OSes have such functionality available, and those that do have different ways of accomplishing it, so this could be more difficult to do in a cross-platform way.

What would be nice is a simple API call to the JVM that would set it if the underlying OS has support, but I cannot find anything of the sort.  So the question is, how can I set the process title for my java app (at least on Linux, if not some other OSes)?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros