I have two javas installed on my pc. jdk1.7.0_45 (x64) and jdk1.6.0_45(x86). I want that default java on my machine would be jdk1.6.0_45(x86). I added JAVA_HOME with value C:\Program Files (x86)\Java\jdk1.6.0_45 and added C:\Program Files (x86)\Java\jdk1.6.0_45\bin to system path, but still when i type in command prompt "java -version" it says:

java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

I have no idea why the things are like that, because my OS should see jdk1.7.0_45 (x64) version. Why is that so?

I use windows 8


edit:

after setting java home to jdk1.7.0_45 (x64) folder and updating path accordingly javac works, but then I set java home and path to jdk1.6.0_45(x86) javac does not work.

有帮助吗?

解决方案

You need to add the %JAVA_HOME%\bin to the very beginning of your path. This is because Java is installed in your %SystemRoot%\system32, too. If you add the %JAVA_HOME%\bin to the beginning of your path the Java installed in your JAVA_HOME will be used.

其他提示

JAVA_HOME does not help when we run java from command line, you should fix PATH system var

I added JAVA_HOME with value C:\Program Files (x86)\Java\jdk1.6.0_45

In Windows, you should excape spaces in the path: JAVA_HOME="C:\Program Files (x86)\Java\jdk1.6.0_45". But the best way is to set Java to a folder that doesn't have spaces in its path. For example, I use C:\Java\Java6

and added C:\Program Files (x86)\Java\jdk1.6.0_45\bin to system path

Probably you added after path to the Java 7. Make sure that Java 7 doesn't exist in the system path.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top