Reputation: 31724
I have this strange Issue with environment variables on my windows 7 system. Its been there for an year and I have had a work around but I need to solve it now:
I have an environment variable JAVA_HOME
set as C:\Program Files\Java\jdk1.6.0_39\
. And in my PATH
I have added %JAVA_HOME%\bin;
.
But when I do java -version
it prints "1.7.0_11"
and when I do javac -version
it prints as expected 1.6.0_39
I do not know why 1.7.0_11
is printed for java -version
. I have checked my PATH
and have added JAVA_HOME only once. How can I know which env variable is responsible for using my java.exe
? How do I avoid it?
Upvotes: 0
Views: 111
Reputation: 115328
Java.exe
is installed on windows twice. The first location is where you expect it: under your JAVA_HOME
. The second one is under c:/windows
. Since this path always wins any other user defined path you are running java from here. If you want to hold several java environments and switch between them by changing your JAVA_HOME
just remove java.exe
from c:/windows
.
Upvotes: 1
Reputation: 6207
Ok, hopefully %JAVA_HOME\bin%;
is a typo, but if not, it should be %JAVA_HOME%\bin
.
For the rest - java -version
is looking for your JRE, not your JDK. javac
is looking for the JDK.
Check to see if you have a JRE-related environment variable. As well, check your path for any hard references to the Java 7 JRE. Finally, look in C:\Windows\System32 and see if there is a java.exe
there.
Upvotes: 1
Reputation: 1499800
It's almost certainly a version of java.exe
in c:\Windows\System32
, which is likely to come earlier in your path than the part which refers to JAVA_HOME
.
Upvotes: 2