reproduced
Windows to install multiple versions of JDK on the same machine, modify the environment variable does not take effect problem handling method
The machine has jdk1.7 installed, and earlier projects need to rely on jdk1.6, so both jdk1.6 and jdk1.7 are installed natively.
Before installing jdk1.6, perform java-version to get
C:\users\liuxiang2>java-version
Java Version "1.7.0_21"
Java (TM) SE Runtime Environment (build 1.7.0_21-B11)
Java HotSpot (TM) Client VMs (build 23.21-b01, mixed mode, sharing)
After installing jdk1.6, and modifying the environment variable Java_home to C:\jdk1.6.0. When you execute java-version again, it still shows:
C:\users\liuxiang2>java-version
Javaversion "1.7.0_21"
Java (TM) SE Runtime Environment (build 1.7.0_21-B11)
Javahotspot (TM) Client VM (Build 23.21-b01, mixed mode,sharing)
It seems that the new environment variable java_home=C:\jdk1.6.0 does not take effect. Find a lot of information on the Internet to find:
When installing JDK1.7 (this machine first installs the jdk1.7 again installs the jdk1.6), automatically copies Java.exe, Javaw.exe, javaws.exe three executable files to the C:\Windows\System32 directory, Because this directory takes precedence over the environment variables set by the Java_home in Windows environment variables
Solution: Remove Java.exe,javaw.exe,javaws.exe from the C:\Windows\System32 directory . When you open a new command-line window, and then execute java-version, you get the desired result.
C:\users\liuxiang2>java-version
Java Version "1.6.0_18"
Java (TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot (TM) Client VMs (BUILD16.0-B13, mixed mode, sharing)
Windows to install multiple versions of JDK on the same machine, modify the environment variable does not take effect problem handling method