I accidentally found one useful feature of Java that I didn‘t know about.
I have many Java versions installed because some programs I have only run
with some or because I need to test a program with a specific version.
Until now to run a program with a specific Java version I used the full
path to the java.exe or javaw.exe of the specific version. But I just
learned that with the "-version" command line parameter not only shows the
version but also let‘s us specify one to use with the form "-version:x"
where x is a Java version. Probably it‘s just searchs for public installed
JVMs and wouldn‘t find privately installed ones. Curiously it understand "-version:1.5" to use the higher 1.5 version I have installed, but it doesn‘t found the 1.4.2_12 when I used "-version:1.4". Examples: I have installed java 1.4.2_12, 1.5.0_08, 1.5.0_10 and 1.6.0. c:\>java -version java version "1.6.0" Java(TM) SE Runtime Environment (build 1.6.0-b105) Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing) c:\>java -version:1.5 -version java version "1.5.0_10" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_10-b03) Java HotSpot(TM) Client VM (build 1.5.0_10-b03, mixed mode, sharing) c:\>java -version:1.5.0_08 -version java version "1.5.0_08" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03) Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing) c:\>java -version:1.5.0_09 -version Unable to locate JRE meeting specification "1.5.0_09" c:\>java -version:1.4 -version Unable to locate JRE meeting specification "1.4" c:\>java -version:1.4.2 -version Unable to locate JRE meeting specification "1.4.2" c:\>java -version:1.4.2_09 -version Unable to locate JRE meeting specification "1.4.2_09" c:\>java -version:1.4.2_12 -version java version "1.4.2_12" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_12-b03) Java HotSpot(TM) Client VM (build 1.4.2_12-b03, mixed mode) |
|