Install and configure multiple versions of JDK


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

Install jdk8

Configure environment variables

Configuration requiredJAVA_HOME CLASSPATH PathCLASSPATHandPathNormal 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}


%{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_HOMEAs shown in the following figure:



Period and semicolon of English characters are in front of them. If you need to add English semicolons after them




Test JDK environment

Open a command prompt and enterjava -version, the correct version information is displayed, that is, the configuration is successful

javajavacThese two commands can also be tested. When a pile of information appears, the configuration is successful