Open In App

How to Install OpenJDK (Free Java) in Windows

Last Updated : 09 Jan, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

We all know that Java is one of the most popular programming languages and comes under the top 10 most used programming languages. Now, if you are starting your Java learning, then you need to install the Java Development Kit (JDK) on your machine. OpenJDK is a free and open-source version of the Java Platform Standard Edition.

This step-by-step guide is one place to know how to install OpenJDK in a Windows system, how to verify the installation, and how to run your first Java program. Also, the procedure you are following in this article is applicable on Windows 10 and Windows 11 also.

System Requirements to Install OpenJDK in Windows

  • OS: Windows 10 (version 1903) and Windows 11 all versions
  • Processor: Minimum 1 GHz processor (Recommended 2 GHz processor)
  • Disk Space: Minimum 300 MB free space
  • RAM: Minimum 2 GB of RAM (Recommended 4 GB)

How to Install OpenJDK (Free Java) in Windows

In this section we are going to discuss the step-by-step process to install OpenJDK in Windows 10 and 11. So, follow the steps and complete the installation process by yourself.

Step 1: Download OpenJDK

  • Open your web browser and go to the official OpenJDK website or visit a trusted distributor like Adoptium or Amazon Corretto.
  • Look for the latest version of OpenJDK that matches your requirements.
  • Download the Windows installer or the ZIP file for the 64-bit version of OpenJDK. Ensure you choose the correct version for your system.

Step 2: Install OpenJDK

If you downloaded the installer

  • Once download is completed double-click on the downloaded installer file.
  • Follow the instructions in the installation wizard.
  • Select the installation directory or use the default one provided.
  • Click “Install” and wait for the installation to complete.

If you downloaded the ZIP file

  • Locate the downloaded ZIP file and extract it to a folder on your computer. For example, you can extract it to C:\Program Files\OpenJDK.
  • Remember the folder path where you extracted OpenJDK, as you will need it later.

Step 3: Set Up Environment Variables

You need to set up environment variables to run Java programs from the command prompt.

  • Open the Start menu and search for “Environment Variables”.
  • Click on “Edit the system environment variables”.
  • In the System Properties window, click on the “Environment Variables” button.
  • Under “System Variables”, find the “Path” variable and select it, then click “Edit”.
  • Click “New” and add the path to the bin folder inside your OpenJDK installation directory. For example, C:\Program Files\OpenJDK\bin.
  • Click “OK” to save the changes.

Step 4: Verify the Installation

  • Open the command prompt by pressing Win + R, typing cmd, and pressing Enter.
  • Type the following command to check the Java version:
    java -version
  • If OpenJDK is installed correctly, you will see the version details displayed in the command promt

Step 5: Run a Java Program

  • Now that OpenJDK is installed and configured, you can run your first Java program.
  • Create a new file named HelloWorld.java using a text editor like Notepad.
  • Write the following code in the file:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
  • Save the file in a folder, for example, C:\JavaProjects.
  • Open the command prompt and navigate to the folder where you saved the file using the cd command.
cd C:\JavaProjects
  • Compile the program using the following command:
javac HelloWorld.java
  • Run the program using the command:
java HelloWorld
  • If everything is set up correctly, you will see the message “Hello, World!” displayed in the command prompt.

Conclusion

You have successfully installed OpenJDK on your Windows computer and run your first Java program. OpenJDK provides a free and reliable way to work with Java, making it an excellent choice for developers. Now you can start learning and building Java applications with ease.


Next Article
Article Tags :
Practice Tags :

Similar Reads