I would like to know if it is possible to get from code the command used to launch a java program.
E.g. if I launch a java program with:
java -cp li
You can use this to retrieve the VM parameters :
public static void main(String args[]) {
List inputArguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
System.out.println("input arguments = " + inputArguments);
}
However it won't give you all the command line (only gives the JVM arguments, no main class nor parameters). Sample output:
input arguments = [-Dfile.encoding=UTF-8, -XX:-UseTLAB, -Xms2000m, -Xmx2000m, -XX:+PrintCompilation, -XX:+PrintGC]