Get the name of the main class / jar file passed to the JVM

As a C ++ application, is there a way to request a java process (java.exe / javaw.exe) to retrieve the name of the main class or jar file that was passed to the JVM? I want to get the same result as when running "jps -l":

C:\>jps -l -V
2644 sun.tools.jps.Jps
4340 net.sourceforge.squirrel_sql.client.Main

I think I can get the command line parameter and try to parse the class name, but I was wondering if there is an easier method to reliably retrieve only the class name or jar file name.

Thanks!

+3
source share
2 answers

RFE, . . , ( ).

+1

, PSAPI. , Win32 .

0

Source: https://habr.com/ru/post/1721938/


All Articles