Reputation: 183
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 environment variable but when I type java -version, the system replies Java 7... How can I switch from different java versions?
Thank you.
Upvotes: 18
Views: 32198
Reputation: 2148
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
Upvotes: 2
Reputation: 1297
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).
Upvotes: 32
Reputation: 76709
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.
Upvotes: 3
Reputation: 691635
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
Upvotes: 3