How can I from within Java code find out which and how the running JVM was launched? My code shall spawn another Java process hence I'd be especially interested in the first parameter - which usually (in C, Pascal, Bash, Python, ...) points to the currently running executable.
So when a Java application is run like
d:\openjdk\bin\java -Xmx500g -Dprop=name -jar my.jar param1 param2
I can access command line parameters in my main method like
public class Main {
public static void main(String[] args) {
System.out.println("main called with " + args);
}
}
but that will deliver access to param1
and param2
only. How would I get the full command line?