Preface: there are multiple versions of JDK. Sometimes it is necessary to switch different versions for development. To install multiple jdks on a computer, you only need to configure them as follows, and you can easily use them each time. The following environments are windows10
Install JDK
Configure environment variables
Configuration requiredJAVA_HOME
CLASSPATH
Path
,CLASSPATH
andPath
Normal configurationJAVA_HOME
, you need to create a custom variable to save the JDK location. The following takes variables jdk1 and jdk2 as examples
Jdk1:{jdk1_; installation location}
Jdk2:{jdk2_installation location}
JAVA_HOME
%{JDK1}%
: jdk1 version is effective
%{JDK2}%
: jdk2 version is effective
This configuration only needs to be changed every time another version of JDK is requiredJAVA_HOME
As shown in the following figure:
CLASSPATH
Period and semicolon of English characters are in front of them. If you need to add English semicolons after them
.;%JAVA_HOME%\lib
Path
%JAVA_HOME%\bin
Test JDK environment
Open a command prompt and enterjava -version
, the correct version information is displayed, that is, the configuration is successful
java
、javac
These two commands can also be tested. When a pile of information appears, the configuration is successful