Why is java -version returning a different version to the one defined in JAVA_HOME?
Run
where java
at your command prompt.
On my system, it printed something quite unexpected:
C:\Users\Mikel>where java
C:\Windows\System32\java.exe
Verifying there really is a Java there:
C:\Users\Mikel>c:\windows\system32\java.exe -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
So one solution is to ensure your preferred Java is in the PATH before C:\Windows\System32
.
I also tried looking in the Java control panel to see if it manages the version in C:\Windows\System32
, but I could only view the settings, not edit them. Maybe it works for you?
As Mikel has mentioned, In your machine java is taken from C:\Windows\System32\java.exe
.
Change the Path in the System Environment variables as mentioned by John T.
And modify it have the C:\bea\jdk150_10\bin
before %SystemRoot%\system32
in the path.
Modify the PATH
variable, not JAVA_HOME
.
See the Java documentation on setting or changing your PATH variable.
Start -> Control Panel -> System -> Advanced
Click on Environment Variables, under System Variables, find
PATH
, and click on it.In the Edit windows, modify
PATH
by adding the location of the class to the value forPATH
. If you do not have the itemPATH
, you may select to add a new variable and addPATH
as the name and the location of the class as the value.Close the window.
Reopen Command prompt window, and run your Java code.