How To Install OpenJDK 15 On Windows

How To Install OpenJDK 15 On Windows

Explains all the steps required to install OpenJDK 15 on Windows and getting started with Java using Hello World example.

October 19, 2020

This tutorial provides all the steps required to install OpenJDK 15 on Windows 10. The steps to install OpenJDK 15 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 15 On Ubuntu to install the latest OpenJDK on Ubuntu and How To Install Java 15 On Ubuntu to install Oracle JDK.

Download OpenJDK

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

Install OpenJDK 15 on Windows 10 - Downloads

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.

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-15.

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

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 2.

Install OpenJDK 15 on Windows 10 - Verify

Fig 2

It shows the version of Java 15 since my current version of Java is 15. In your case it might show another version of the 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 15 on Windows 10 - Advanced Settings

Fig 3

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

Click on New Button and add the path to installed JDK bin which is C:\java\openjdk\jdk-15\bin in our case. You might be required to update the path if it already exists. It should look like the one shown in Fig 4.

Install OpenJDK 15 on Windows 10 - System Path

Fig 4

Press OK Button 3 times to close all the windows. This sets the JDK 15 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 15 on Windows 10 - System 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 newly installed OpenJDK 15.

Install OpenJDK 15 on Windows 10 - Verify

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 HelloWorld.java 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
javac HelloWorld.java

# 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.

Summary

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

Write a Comment
Click the captcha image to get new code.
Discussion Forum by DISQUS