To get started to develop or run Java applications, a Java Development Kit (JDK) is required. And OpenJDK is an open-source and production-ready distribution of JDK. So in this article, I’d like to share how to setup OpenJDK version 21 on Windows operating system, step by step.

JDK 21 is the latest Long Term Support (LTS) release of Java SE platform (as of December 2023). It was released on September 19th 2023.

Kindly follow the steps below to setup JDK 21 on Windows OS with OpenJDK.

 

1. Download binary distribution of OpenJDK 21

You should download the binary distribution of OpenJDK from a trusted source, i.e. JDK 21’s official download page. The following page will appear:

OpenJDK 21 download page

You see, OpenJDK 21 is distributed as zip archive for Windows - no installer or setup program. That means you must download and install it manually.

So click the hyperlink “zip” next to Windows/x64 as shown in the above screenshot. It will download the zip file openjdk-20.0.1_windows-x64_bin.zip on to your computer.

Next, it’s strongly recommended to verify integrity of the downloaded archive by checking its SHA256 checksum. Open a new Command Prompt window at the directory that contains the file, and type the following command:

certutil -hashfile openjdk-21.0.1_windows-x64_bin.zip sha256



If the SHA256 value printed is identical to the one published in the hyperlink ‘sha256’ shown above, it’s safe to use the downloaded zip file to install OpenJDK 21.


2. Install OpenJDK 21 on Windows

You can extract the downloaded zip file using Windows Explorer or the following command in Command Prompt window:

tar -xf openjdk-21.0.1_windows-x64_bin.zip

It will unzip the file to a new directory named jdk-21.0.1 which contains the binary files of OpenJDK 21.

Then you need to set the system environment variables JAVA_HOME and PATH in the following manner:

       JAVA_HOME = [Path to OpenJDK directory]

       PATH = JAVA_HOME\bin + PATH

For detailed instruction about setting up JAVA_HOME environment variable, check this article.

And to verify the installation of OpenJDK, open a new command prompt window and type java -version to and javac -version as shown below:

check openjdk java 21 version

If it prints openjdk version “21.0.1” and “javac 21.0.1”  - that means you have installed OpenJDK 21 on Windows operating system successfully. You now can begin developing and running applications on Java virtual machine. 

Watch the following video to see how to download and install OpenJDK 21 on Windows in action:

 

Learn more:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment