Java 7 64 bit on windows 7: how to switch java versions

后端 未结 4 1740
悲哀的现实
悲哀的现实 2021-01-03 23:05

I need to switch from the installed java 7 at 64bit to the installed java 6 on my Windows 7 64bit OS but the usual procedure doesn\'t works. I tried to change the JAVA_HOME

相关标签:
4条回答
  • 2021-01-03 23:43

    You need to switch the path environment variable too, to point before to the JRE bin directory. Also, I think modern versions of java place a copy of "java.exe" in the system32 directory of Windows, you'll need to remove them (or rename them, if you want to keep them as backups).

    0 讨论(0)
  • 2021-01-03 23:50

    JAVA_HOME is not used by java.exe.

    Make sure to have the path of the Java 6 JRE's bin directory in the PATH environment variable, before the Java 7 JRE's one, and before windows system directory (system32).

    Or you can use the full path of the java command:

    c:\java6\bin\java com.foo.bar.Main
    
    0 讨论(0)
  • 2021-01-03 23:53

    Windows relies on PATH environment variable and not JAVA_HOME to lookup executables including the Java application launcher java.exe. While the JAVA_HOME environment variable may be used in the PATH environment variable, it need not be the case, so you must modify the PATH environment variable to use JAVA_HOME or the new Java 6 installation home.

    0 讨论(0)
  • 2021-01-04 00:02

    Since Java supports a "-version" command line option. You can use this to select a specific version to run, e.g.:

    java -version:1.7 -jar [path to jar file] will run a jar application in java 1.7, if it is installed.

    See Oracle's documentation here: http://docs.oracle.com/javase/6/docs/technotes/tools/windows/java.html

    0 讨论(0)
提交回复
热议问题