开发者

Retrieve main class/jar file name passed to the JVM

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!


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).


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜