分享

One java.exe for all java versions

 lwj888 2007-03-25
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)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多