How To Install OpenJDK 18 On Windows

By bhagwatchouhan
How To Install OpenJDK 18 On Windows

This tutorial provides all the steps required to install OpenJDK 18 on Windows 10. The steps to install OpenJDK 18 on other versions of Windows should be similar to the steps explained in this tutorial.

You may also install the popular IDEs to develop Java applications by following - How To Install Eclipse For Java On Windows, How To Install IntelliJ IDEA for Java on Windows, and How To Install VSCode For Java On Windows. You may also follow the How To Install OpenJDK 18 On Ubuntu to install the latest OpenJDK on Ubuntu and How To Install Java 18 On Ubuntu to install Oracle JDK.

Step 1 - Download OpenJDK

Open the JDK 18 GA Release site and download the distribution for Windows as highlighted in Fig 1.

Install OpenJDK 18 On Windows 10 - Download Options

Fig 1

Click the zip download link as highlighted in Fig 1 to download OpenJDK for Windows. Also, verify your download using the given sha256 checksum.

Step 2 - Install OpenJDK

Extract the downloaded zip to the desired location. In my case, I have extracted the downloaded zip to C:\java\openjdk. The final path should be C:\java\openjdk\jdk-

This is the only step required to install OpenJDK on windows.

Step 3 - Set Environment Variables

In this step, we will configure the environment variables to use the OpenJDK from Command Prompt. Open Command Prompt and check the installed version of Java using the command java -version as shown in 

Fig 1

Install OpenJDK 18 On Windows 10 - Verify Installation

Fig 2

It shows the version of Java 18 since my current version of Java is 18. In your case it might show another version of Java if it's already installed, else it will show the message - Java is not recognized as internal or external command, operable program or batch file.

Right Click -> My Computer(This PC) -> Properties -> Advanced System Settings

The above steps will open the Windows Settings Panel as shown in 

Fig 3

Install OpenJDK 18 On Windows 10 - Path - Advanced Options

Now click the Environment Variables Button, select Path under the System Variables section, and click the Edit Button. We need to add the path of installed JDK to the system Path.

Click on the New/Edit Button and add/update the path to the installed JDK bin which is C:\java\openjdk\openjdk-\bin in our case. You might be required to update the path if it already exists.

Press the OK Button 3 times to close all the windows. This sets the JDK 18 on system environment variables to access the same from the console.

Notes: Remove existing PATH values specific to previously installed Java. Also update JAVA_HOME, in case it was already set. Also, you might be required to remove the previously installed JDK from the Global Path as shown in 

Fig 5.

Install OpenJDK 18 On Windows 10 - Remove Path

Fig 5

Now again open the console and test the Java version as shown in Fig 6. Make sure to use a new console to test the version of the newly installed OpenJDK 18.

Install OpenJDK 18 On Windows 10 - Verify Installation

Fig 6

It must show the OpenJDK version as shown in Fig 6. You might need to restart the system in case it does not reflect the JDK version installed by us.

Getting started with Java - Hello World

In this step, we will write, compile, and execute our first program in Java using the standard Hello World example.

Now write the first Java program as shown below, save the program as and exit the editor. Make sure that the class name and file name are the same.

class HelloWorld {

public static void main( String[] args ) {

System.out.println( "Hello World !!\n" );

Now open the command prompt and navigate to the path where you have saved your Java program. Use the below-mentioned commands to compile and execute the program.

# Compile - Specify file name and extension

# Execute - Spicy file name
java HelloWorld

# Output
Hello World !!

These are the easy-to-install steps required to install OpenJDK on Windows and write and execute the Java program.


This tutorial provided the steps required to download and install the most recent versions of OpenJDK i.e. JDK 18 and also provided the steps to write, compile, and execute the first Java program.


share on :

Profile picture for user bhagwatchouhan