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++应用程序,是否有一种方法可以查询java进程(java.exe/java .exe)来检索传递给JVM的主类或jar文件名?我希望得到与运行“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.
我想我可以获取命令行参数并尝试解析类名,但是我想知道是否有更简单的方法可以可靠地提取类名或jar文件名。
Thanks!
谢谢!
2 个解决方案
#1
1
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).
几年前,我确实提交了一个RFE来将主类名作为系统建议。主类的系统属性。就我所知,如果不修改主类(可以通过插装实现),就没有一种很好的方法来实现这一点。
#2
0
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.
您可能会从PSAPI得到您想要的。如果从那里开始,您可以导航到所有其他Win32,以便从流程中挖掘信息。
#1
1
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).
几年前,我确实提交了一个RFE来将主类名作为系统建议。主类的系统属性。就我所知,如果不修改主类(可以通过插装实现),就没有一种很好的方法来实现这一点。
#2
0
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.
您可能会从PSAPI得到您想要的。如果从那里开始,您可以导航到所有其他Win32,以便从流程中挖掘信息。