Reputation: 1007
As a C++ app, is there a way to query a java process(java.exe/javaw.exe) to retrieve the main class or jar file name that was passed to the JVM? I want the same result as when you run "jps -l":
C:\>jps -l -V
2644 sun.tools.jps.Jps
4340 net.sourceforge.squirrel_sql.client.Main
I think I could get the command line parameter and try to parse for the class name, but I was wondering if there is simpler method to extract only the class name or jar file name reliably.
Thanks!
Upvotes: 4
Views: 652
Reputation: 147164
Years ago I did submit an RFE to present the main class name as a system propterty. System property for main class. As far as I know there is not a good way to do this without altering the main class (which could be done through instrumentation).
Upvotes: 2
Reputation: 100050
You might get what you want from PSAPI. If you start there, you can navigate to all the other Win32 for dredging information out of processes.
Upvotes: 0