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
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).
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
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.
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