How to install Java Development Kit (JDK) on Windows

Introduction

Installation of Java Development Kit is required for software development using Java language. For most cases (learning Java, creating your own projects) installing the latest version of JDK is the best option (see the next section). For enterprise development you should consider using the LTS version of Java (8, 11 ,17 etc) (follow “Installing certain version of JDK” section).

Installing the latest version of JDK

1. Download JDK

To install java follow the link https://jdk.java.net/.
Here you should choose the latest version of Java Development Kit (in my case it is JDK 20).

Choosing latest JDK version

Then choose right build for your system.

Choosing JDK build

2. Unzip and copy files

After the download is finished, unzip the loaded file into some directory. In my case that would be C:\Program Files\Java\jdk-20.0.1. Content of the directory should look like this:

Unzip and copy JDK files

3. Configure the system environment variables

Last step is to configure path to Java Development Kit in Windows system variables. Press Win then start typing “Edit the system environment variables” and open it (or alternatively press Win+R , type “systempropertiesadvanced” and press Enter).

Open system variables editor

Click the “Environment variables…” button.

Open system variables editor

In this window you could see environment variables for current user and system variables (available for every user). To create a system variable press “New…”.

Create JAVA_HOME variable

Enter “JAVA_HOME” as variable name and path to your JDK as variable value. Then press “OK”.

Configure JAVA_HOME variable

Now we will add our new system variable to the “Path“. To edit “Path” variable just double click it.

Edit Path variable

In the new window you’ll see a list of all variables added to Path. Just press the “New” button.

Add new entry to Path variable

Enter %JAVA_HOME%\bin. Here we refer to our “JAVA_HOME” variable using percent signs. After that close all windows pressing “OK” to save all changes.

Path with added JAVA_HOME

4. Check that everything is set properly

Now lets check that everything is set right. Press Win then type “cmd” and open it (or alternatively press Win+R , type “cmd” and press Enter).

Open cmd

In opened command line type java -version and press Enter. You should see the current java version.

Checking java version

Installing certain version of JDK

You can access OpenJDK archive at https://jdk.java.net/archive, here you can find list of all previous JDK version. Download zip file for JDK 17 (current long time support version) and then just follow installation steps from 2 to 4.

Choose LTS JDK build

The problem with these archived versions is that they don’t have all the latest patches. So you can download JDK distributions with latest patches at https://adoptium.net/marketplace/ , https://aws.amazon.com/corretto/ , https://www.oracle.com/java/technologies/downloads/ etc and install them similarly. Just don’t forget to check the license agreement of the distribution so it is suitable for your project.

Scroll to Top