About switching when using multiple versions of JDK installed on the computer

Reprinted from: https://www.cnblogs.com/yanzige/p/5377332.html

The specific operations and descriptions are as follows ( the first two methods were unsuccessful )

Originally installed jdk1.7, the environment variable is also the 1.7 related path configured, after entering [java -version] under cmd, it displays

C:\Users\Administrator>java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

 

1. Download and install the jdk1.6 version, and install it successfully. Change the relevant paths in the environment variables as follows:

At this time, after entering [java -version] under cmd, it still displays

C:\Users\Administrator>java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

] means that the jdk version switch is not successful.

This method is unsuccessful

 

2. Find the Control Panel, select Large Icons or Small Icons for View, find the java option and click to enter. Then select the java column, click View, and remove the jdk1.7 enable, and save:

After entering [java -version] under cmd, it displays

C:\Users\Administrator>java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

This method is unsuccessful

 

4. Find the directory C:\Windows\System32 and delete java.exe, javaw.exe and javaws.exe.

When I open a new command line window and execute java -version again, I get the expected result

C:\Users\Administrator>java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01, mixed mode)

 

Successfully modified

Reason: Since the priority in the WINDOWS\System32 environment variable is higher than the environment variable priority set by JAVA_HOME, if only the environment variable JAVA_HOME is modified, the jdk version will not be switched.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325076153&siteId=291194637