Run the following in Windows:
java -version:1.5+
echo %ERRORLEVEL%
If you run it with Java 5 or Java 6, you’ll get an exit code of 0 meaning success (meaning the version is at least 1.5).
If you run it with Java 7, you get exit code 1, which means failure.
Anyone run into this and know what happened?
-version:<value>syntax is intended to request launcher to do something with specific version of JVM. I.e. run your Java application, or print version (-?). But target is not specified, and it is an error. Launcher prints usage and returns1. Same as running plainjava.exewithout any parameters. I believe that behavior observed in previous releases is just a minor bug fixed in Java 7.EDIT You could run
java -version:1.5+ -version. This requests launcher check available VMs and print version (that is always successful operation). Less verbose than-?option.The other option is create some stub class with main method that will do nothing. Then successful check will be completely silent.
java -version:1.5+ your.stub.MainClass