File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Identifying Java Processes on UNIX boxes

 
Graham Kelly
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • 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'
 
Vlado Zajac
Ranch Hand
Posts: 245
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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).
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic