OpenJDK is an open-source implementation of the Java Platform and is widely used for Java development, programming courses, enterprise applications, Minecraft servers, Android-related tools, and many other software projects. If you want to compile and run Java programs on Windows 11, installing a Java Development Kit (JDK) is usually the first step.
OpenJDK provides the Java runtime and development tools required to compile Java source code and run Java applications. Windows 11 users can install it manually using a JDK distribution or use a package manager such as Windows Package Manager.
This guide explains how to download, install, configure, and verify OpenJDK on Windows 11.
Method 1: Download OpenJDK for Windows 11
Before installing Java, choose an OpenJDK distribution that supports Windows 11.
Several OpenJDK builds are available, and the installation process is generally similar. For a straightforward setup, download a Windows installer for a supported long-term-support JDK release.
When choosing the download:
- Select Windows as the operating system.
- Choose x64 if you are using a standard 64-bit Windows 11 PC.
- Select an appropriate JDK release.
- Download the Windows installer, if one is available.
- Avoid downloading a JRE when you need to compile Java programs.
The JDK is different from the Java Runtime Environment because it includes development tools such as the Java compiler.
After downloading the installer, locate the downloaded file in your Downloads folder.
Method 2: Install OpenJDK Using the Windows Installer
Once you have downloaded an OpenJDK installer, you can install it like most other Windows applications.
Follow these steps:
- Open the downloaded OpenJDK installer.
- If Windows displays a User Account Control prompt, click Yes.
- Follow the installation wizard.
- Review the license information.
- Select the installation location.
- Continue with the installation.
- Wait for the files to be copied.
- Click Finish when the installation is complete.
The default installation directory depends on the OpenJDK distribution you selected.
For example, a JDK may be installed somewhere under:
C:\Program Files\
Do not worry if your exact folder name is different. Different OpenJDK distributions and versions use different directory structures.
After installation, Java may already be added to your Windows PATH. If it is not, you can configure it manually.
Method 3: Install OpenJDK Using Windows Package Manager
Windows 11 includes Windows Package Manager on supported installations, allowing you to install many applications directly from Windows Terminal.
To check whether winget is available, open Windows Terminal and run:
winget --version
If Windows returns a version number, Windows Package Manager is available.
You can search for available OpenJDK packages with:
winget search OpenJDK
The results may contain multiple OpenJDK distributions and versions.
Choose a package that matches your requirements and install it using its package ID. For example:
winget install --id <PACKAGE_ID>
Replace <PACKAGE_ID> with the ID shown in the search results.
Using winget can be useful because it simplifies installation and makes it easier to update software later.
The exact package names and IDs can change as repositories and JDK versions are updated, so searching first is preferable to relying on an outdated package ID.
Method 4: Configure JAVA_HOME in Windows 11
Some Java applications and development tools look for the JAVA_HOME environment variable to locate the JDK.
If your OpenJDK installer did not configure it automatically, you can add it manually.
First, find the directory where OpenJDK was installed.
For example:
C:\Program Files\OpenJDK\jdk-<version>
Your actual path will depend on the JDK distribution and version.
Then configure the variable:
- Press Windows + S.
- Search for environment variables.
- Select Edit the system environment variables.
- In the System Properties window, click Environment Variables.
- Under System variables, click New.
- Enter:
JAVA_HOME
- For the value, enter the path to your JDK installation.
- Click OK.
Next, find the Path variable under the appropriate variables section.
Select it and click Edit.
Add:
%JAVA_HOME%\bin
Click OK to save the changes.
Close and reopen Windows Terminal or Command Prompt so that the new environment variables are loaded.
Method 5: Verify the OpenJDK Installation
After installing OpenJDK, verify that Windows can find Java.
Open a new Command Prompt or Windows Terminal window and run:
java -version
You should see information about the installed Java version.
Then check the Java compiler:
javac -version
A successful result from both commands confirms that the JDK and its compiler are available.
You can also check the location Windows is using:
where java
And:
where javac
These commands display the executable locations discovered through your PATH.
If java works but javac does not, you may have only a Java runtime available through PATH or your JDK’s bin directory may not be configured correctly.
If neither command works, check your installation and environment variables.
Method 6: Compile and Run a Test Java Program
The easiest way to confirm that OpenJDK is fully functional is to compile a small Java program.
Open Notepad and enter:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Save the file as:
HelloWorld.java
Make sure that Windows does not save it as HelloWorld.java.txt.
Open Command Prompt and navigate to the folder containing the file.
For example:
cd C:\Users\YourName\Desktop
Compile the program:
javac HelloWorld.java
If compilation succeeds, Windows will create a class file.
Run the program with:
java HelloWorld
You should see:
Hello, World!
This confirms that OpenJDK can compile Java source code and execute the resulting application.
Method 7: Fix Common OpenJDK Installation Problems
OpenJDK installation problems on Windows 11 are usually related to PATH configuration, incorrect installation directories, or multiple Java versions.
java is not recognized
If you see:
'java' is not recognized as an internal or external command
Windows cannot find the Java executable through PATH.
Check where OpenJDK was installed and make sure its bin directory has been added to PATH.
For example:
C:\Program Files\OpenJDK\jdk-<version>\bin
The actual path will depend on your installation.
Close and reopen Command Prompt after changing PATH.
javac is not recognized
If:
java -version
works but:
javac -version
does not, check whether your PATH points to a JRE or another Java installation instead of the JDK.
Adding the correct JDK bin directory to PATH should resolve the issue.
The wrong Java version is displayed
If multiple Java versions are installed, Windows may find an older installation first.
Run:
where java
This shows the Java executable locations Windows can find.
Review your PATH entries and ensure that the JDK version you want to use appears in the appropriate position.
You can also check:
echo %JAVA_HOME%
to see whether JAVA_HOME points to the intended JDK.
JAVA_HOME points to the wrong directory
JAVA_HOME should normally point to the JDK’s main installation directory, not directly to its bin directory.
For example:
C:\Program Files\OpenJDK\jdk-<version>
rather than:
C:\Program Files\OpenJDK\jdk-<version>\bin
Your exact directory will vary by distribution.
Conclusion
Installing OpenJDK on Windows 11 gives you the tools required to develop, compile, and run Java applications. You can install it using a Windows installer or, when supported, use Windows Package Manager to simplify the process.
After installation, verify both java and javac from a new Windows Terminal or Command Prompt window. If necessary, configure JAVA_HOME and add the JDK’s bin directory to your PATH.
Finally, compiling and running a simple Java program is a reliable way to confirm that the complete JDK installation is working correctly.
FAQs
1. Is OpenJDK the same as Java?
OpenJDK is an open-source implementation of the Java platform. Different organizations provide OpenJDK distributions, but they are based on the OpenJDK project.
2. Do I need the JDK or JRE to program in Java?
You need the JDK if you want to develop and compile Java programs. The JDK includes development tools such as javac.
3. Why does java -version work but javac -version fail?
This usually means Windows is finding a Java runtime but not the JDK compiler. Check your PATH and make sure the bin directory of your OpenJDK installation is included.
4. How can I check which Java version Windows is using?
Open Command Prompt or Windows Terminal and run:
java -version
To see where the executable is located, use:
where java
These commands help identify both the active Java version and its installation path.
Quick Summary
- Download a supported OpenJDK distribution for Windows 11.
- Install it using the Windows installer or Windows Package Manager.
- Configure
JAVA_HOMEand PATH if they were not set automatically. - Verify
javaandjavac, then compile a simple Java program to test the installation.





