I've written a program that outputs a usage hint. It currently echos back the path to the main jar file as was originally entered on the command line.
Usage: java -jar path/to/MyJar.jar <params> ...
For completeness, I'd like to make sure that the java bit is echoed back as well, as there are various ways to access java, (beyond just the word java, and shorter than the canonical path to /us/opt/java-1.8.0-u123/bin/java)
Usage: /us/opt/java7/bin/java -jar MyJar.jar <params> ...
Usage: ./bin/java -jar MyJar.jar <params> ...
Usage: java -jar MyJar.jar <params> ...
# whatever the user typed in
How can I determine what command-line was used to evoke the JVM?
I would like the original command-line value, prior to evaluating symbolic links.
I'm not using System.getProperty("java.home") because it has no respect for the original command-line value, just the final 'canonical' location of the JVM. (Having a usage note like Usage: /us/opt/java-1.8.0-u123/jre/bin/java -jar ... would be rather verbose,
especially when using simple java on the command line.)
Is determining the command-line location of java possible using pure Java code?
(i.e. not using a wrapper script in bash)