简体   繁体   中英

How to specify a version of JDK on windows7?

The thing is i have jdk1.6.0_45, jdk1.7.0_09 installed on my computer. Normally i use JDK7 as my work environment with following system variable setting:

JAVA_HOME=C:\Program Files\Java\jdk1.7.0_09;
classpath=%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
path=%JAVA_HOME%\bin;

And when i execute java -version in cmd, it displays the version correctly:

java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)

Here i encounter a problem, i need to switch to JDK6 for another project. So i changed system variable JAVA_HOME to C:\\Program Files\\Java\\jdk1.6.0_45 , i supposed that it should works for the new setting. But actually not, when i executed java -version , it still shows the currently using jdk is 1.7.0_09.

Is this alright?

Finally i found what the problem is. There is a java.exe(which is jdk7) under system32 folder. The full path system variable is path=C:\\Windows\\system32;%JAVA_HOME%\\bin; . Which means the unexpected java7 will always be the selected version on my computer even i have specified another version(like jdk6). It might came along with some browser plugin/applet. When i removed this java.exe, everything goes fine.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM