How to Install Java 21 on Windows 11

Ready to code on the latest Windows 11? Java is an essential tool for many developers. In this comprehensive guide, we're going to explore the steps to install Java 21 on Windows 11 seamlessly. Get ready to gear up your Windows 11 machine for Java development!

Java 21 is the latest version developed by Oracle. Java is one of the most widely used programming languages today. With its extensive libraries and multi-platform capabilities, it's a favorite for both newbies and professionals.


  • A computer running Windows 11.
  • Stable internet connection for downloading the installation files.

Installation Steps

1. Visit the Official Java Website:

Navigate to the JDK Development Kit 21.0.1 downloads.

2. Download the Installer:

Find the version labeled x64 Installer and click on it to start the download.

3. Run the Installer:

Once the download is complete, navigate to the downloaded .exe file, and double-click on it to run the installer.

4. Follow the Installation Wizard:

The installation wizard will guide you through the process. Typically, the default settings are good for most users. Click next through the steps.

5. Set the JAVA_HOME Variable (Optional but Recommended):

Here's a step-by-step guide on how to set the JAVA_HOME variable in Windows 11: 

Locate Your Java Installation Directory

Typically, the JDK is installed in a directory under C:\Program Files\Java. You'll often find a folder with a name like jdk-21 (or another version number). Note down this path. 

Open the Start Menu 

Click on the Windows icon in the bottom-left corner of the screen. Search for "Environment Variables" Type in "Edit the system environment variables" and select the related search result. 

System Properties Window 

In the System Properties window that appears, click on the "Environment Variables" button located at the bottom right. 

Environment Variables Window 

Under the "User variables" section, check if there's an existing JAVA_HOME entry. If JAVA_HOME already exists: Select it and click on the "Edit" button. 

In the "Edit Environment Variable" window, update the "Variable value" with the path to your JDK installation. 

If JAVA_HOME doesn't exist: Click on the "New" button under "User variables". For the "Variable name," type in JAVA_HOME. For the "Variable value," paste or type in the path to your JDK installation. 

Update System PATH (Optional but Often Useful) 

In the "System variables" section, scroll down and find the "Path" variable. Select it and click on the "Edit" button. 

In the "Edit Environment Variable" window, click on the "New" button and then paste or type %JAVA_HOME%\bin. This step ensures that tools such as the Java compiler (javac) and the Java runtime (java) can be run from the command line in any directory without having to type the full path of the commands. 

Apply Changes 

Click on the "OK" button to close each of the windows. 

Verify the Configuration 

Open a new Command Prompt. (It's important to open a new one because changes to environment variables don't get recognized in already opened command prompts.) 

Type in echo %JAVA_HOME% and press Enter. This command should display the path to your JDK installation. 

6. Verification:

To make sure everything is set up correctly, open Command Prompt and type java -version. This should display the version of Java you just installed.

Voila! You've successfully installed Java 21 on your Windows 11 machine. Ready to embark on your Java programming journey?