• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Identifying Java Processes on UNIX boxes

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, not sure this is the correct forum, but the UNIX forum seems to be more about UNIX than Java.

Does anyone know of a way to identify the classes running on a java VM within UNIX? 'ps' only shows the 'java' process. 'ps -f' shows a certain amount fo the actual command line used to run the JVM, but in most cases, the first arg is the classpath, so you don't get to see the actual class or jar that is being run (i.e. the class containing main).

Is there a way to query the JVM to get the main class? Possibly a 'jps'
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

shows complete command lines. (suse linux)

You only need to redirect ps to another program or file.
 
Graham Kelly
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry. I should have mentioned the UNIX flavour. I'm using HP UX 11. The ps command only returns a shortened command line, as in:

corbausr 6107 1 0 Nov 9 ? 3:12 /opt/java1.3/bin/../bin/PA_RISC2.0/native_threads/java -clas

As you can see, it's barely started the argument to specify the CP, never mind the actual class to run.

I found on the web examples saying 'ps -exf', but the 'x' argument reports an error in my flavour of UNIX. I 'man'ed ps and it talks about the -o argument to giva the actual columns I'm interested in, but that's only applicable to 'XPG4' and, again, doesn't work with my flavour.

I was thinking there may be some java way to do this rather than a UNIX way.

I found a utility called 'grash' that allows you to explore the JVM in a UNIX like manner, but that's experimental and I can't use it in production code (anyway, it needs to be imported and used by the class, not an outside process, though I could have it initiated by a hook that the outside process connects to).
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You sure that output isn't to do with your terminal line settings? Seems odd ps is truncating the response. Try it with a --cols switch.

There isn't a Java way to do this that I can think of - processes are always the domain of the OS.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In all of the flavors of unix that I played with, "ps" always truncated the lines, if the output is going to the terminal. If you pipe it to a program, such as "grep", it will not truncate.

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic