Home » Java » How to install different versions of Java JDK on windows

How to install different versions of Java JDK on windows

Sometimes you want to install and switch between different types of JDK versions according to your requirements.

Linux based systems like Ubuntu provides a very easiest way to install and switch between different types of JDK versions. If you want to do it on windows, you have to do it manually by changing the path of the bin folder of different JDK installations.

But in this tutorial, I’m going to show you a very easiest way to install different types of JDK and switch between them according to your requirements.

Note: If your system already has any version of Java please remove the path from the environment variables. There are a lot of resources on the internet to do that.

Download different versions of Java JDK s

You can download different versions of Java jdk from here. I downloaded Java jdk 12.0.1, 11.0.3 (need to login), 1.8.0(need to login).

Install Java JDK s

Install all version of JDK using the downloaded files as usual. Here, I will show the steps for Java 11.0.3.

Install Java jdk step 1
Install Java jdk step 2
Install Java jdk step 3
Install Java jdk step 4

After installing all java JDK versions, I have “jdk1.8.0_111”, “jdk-11.0.3” and “jdk-12.0.1” in the “C:\Program Files\Java” folder.

Installed Java versions

Create .bat files

Create a new folder. Here, I’m going to create a new folder called “dev” in “C drive”.

New folder - /java jdk instalation

Now create a new file called “jdk8.bat”. It is a simple windows batch file. Then paste the following code snippet in that file. Make sure to update the values of JAVA_HOME environment variable according to yours. You should set in obviously to the directory that contains java installation. In my case, it is “C:\Program Files\Java\jdk1.8.0_111”. Now we have to do one more thing. It is updating your “PATH” variable. Set it to “%JAVA_HOME\bin;%PATH%”.

@echo off
echo Setting JAVA_HOME
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_111 
echo setting PATH
set PATH=%JAVA_HOME\bin;%PATH%
echo Display java version
java –version

Then simply copy and paste that file with the name of “jdk11.bat” and “jdk12.bat”. Now at that files you need to simply change “JAVA_HOME” in to “C:\Program Files\Java\jdk-11.0.3” and “C:\Program Files\Java\ jdk-12.0.1”

Now my “dev” folder is  like this.

Java jdk intallation - .bat files

Adding environment variables

The last thing you need to do is adding the path of the “dev” folder to environment variables to able to call from everywhere on your system by command prompt.

In the Environment Variables under the User variables, select “path” -> “edit”.

Java jdk installation path setting

In the Edit Environment variable window, click on “new” -> add path of the dev folder -> click on OK

path setting Java jdk instalation

Then click on “OK” in every window and then simply open up a new command window and run command, “jdk8”. As you can see how your system uses JDK version 8. Then run the command “jdl11” and “jdk12”. They switch the Java JDK version of your system. 

See more java tutorials from here.

Please follow us:
error
Summary
Aggregate Rating
no rating based on 0 votes
Software Name
Java jdk 8, 11, 12
Operating System
Windows

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

FACEBOOK
FACEBOOK
YOUTUBE
YOUTUBE