How To Install OpenJDK 14 On Windows

How To Install OpenJDK 14 On Windows

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

March 18, 2020

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

Download OpenJDK

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

Download OpenJDK 14

Fig 1

Click on the zip download link 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\java-14. The zip extractor will extract the files to C:\java\java-14\jdk-14.

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.

Java Version Test

Fig 2

It shows the version of Java 13 since my current version of Java is 13. 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.

Advanced System Settings

Fig 3

Now click on Environment Variables, select Path under System Variables section and click on Edit. 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\java-14\jdk-14\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.

Java Environment Variable

Fig 4

Press OK Button 3 times to close all the windows. This sets the JDK 14 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.

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

Java Version Test

Fig 5

It must show the OpenJDK version as shown in Fig 5. 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.

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