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?
几乎可以肯定,它是c:\\Windows\\System32
中java.exe
的版本,它的路径可能要比引用JAVA_HOME
的部分早。
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.
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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.