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
Joined: Aug 03, 2004
Posts: 244
posted
0
shows complete command lines. (suse linux)
You only need to redirect ps to another program or file.
Graham Kelly
Greenhorn
Joined: Nov 11, 2004
Posts: 3
posted
0
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).
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.