How to Install JDK on Windows 11: Step-by-Step
In this article
To install the JDK on Windows 11, download the official installer from Oracle or Adoptium, run it, accept the defaults, and then set the JAVA_HOME environment variable so tools like Maven, Gradle, and IDEs can find Java. The whole process takes about ten minutes and needs no special hardware.
What You'll Need
- A Windows 11 PC with administrator rights (you'll need to approve the installer and edit system settings).
- An internet connection to download the installer.
- About 300 MB of free disk space for the JDK itself, plus room for any IDE you add later.
- A browser to reach the official download page.
Step-by-Step
- Pick a JDK distribution. Oracle JDK is the reference build; Eclipse Temurin (from Adoptium) is a free, widely used alternative. Both work the same way for development. Download only from the vendor's official site.
- Download the Windows x64 installer. On the download page, choose the .msi or .exe installer for 64-bit Windows. Avoid the zip archive unless you specifically want a portable install. The exact button labels vary slightly by vendor and version.
- Run the installer. Double-click the downloaded file. If Windows shows a SmartScreen prompt, click More info and then Run anyway only if you downloaded from the official source.
- Accept the defaults. Click Next through the welcome screen, keep the default install location (usually under C:\Program Files\), and let the installer add the java and javac commands to the PATH if it offers that option. Click Install, approve the UAC prompt, and then Finish.
- Open a new terminal. Close any Command Prompt or PowerShell windows you had open, then open a fresh one. Environment changes only apply to new windows.
- Verify the install. Type
java -versionand press Enter. You should see the version number and vendor. Then typejavac -versionto confirm the compiler is present. - Set JAVA_HOME. Open the Start menu, search for environment variables, and choose Edit the system environment variables. In the System Properties window, click Environment Variables. Under System variables, click New, set the name to
JAVA_HOMEand the value to your JDK folder (for exampleC:\Program Files\Java\jdk-21). Click OK. - Add JAVA_HOME to PATH (if needed). In the same Environment Variables window, select the Path variable and click Edit. Add a new entry
%JAVA_HOME%\binif the installer did not already add the JDK's bin folder. Click OK on every window to save. - Re-check in a new terminal. Open another fresh Command Prompt and run
echo %JAVA_HOME%. It should print the path you set. Runjava -versiononce more to confirm everything still resolves.
Common Mistakes
- Forgetting to open a new terminal. If
java -versionsays the command is not recognized right after installing, the old window is still using the old PATH. Close it and open a new one. - Pointing JAVA_HOME at the bin folder. JAVA_HOME must be the JDK root (the folder that contains bin), not bin itself. Tools like Maven fail when this is wrong.
- Installing the JRE instead of the JDK. The JRE only runs Java programs; it does not include javac, so you cannot compile code. Always choose the JDK package.
- Mixing 32-bit and 64-bit builds. On Windows 11, use the 64-bit installer to match the OS.
- Downloading from a third-party mirror. Use only the vendor's official download page to avoid tampered installers.
Tips
- Install the JDK before your IDE (IntelliJ IDEA, Eclipse, VS Code with the Java extension) so the IDE can detect it automatically.
- If you need multiple Java versions, install each into its own folder and switch JAVA_HOME when you switch projects.
- Keep the installer file until you have verified the install, in case you need to repair it.
- Run
where javain Command Prompt to see which Java executable Windows is actually using; this helps when an older Java is shadowing the new one.
Troubleshooting
If java -version reports an older version than you just installed, another Java entry is earlier in PATH. Open Environment Variables, inspect the Path list, and move %JAVA_HOME%\bin above the older entry. If the command is not recognized at all, confirm the JDK's bin folder is in Path and that you opened a new terminal after saving.
If the installer fails or rolls back, check that you have administrator rights and enough disk space, then re-run the installer. If Windows blocks the file, verify you downloaded it from the official site before allowing it. If an IDE still cannot find Java, point it manually at the JDK folder in the IDE's project or SDK settings.
If you see an error about JAVA_HOME being invalid when running Maven or Gradle, re-open the environment variables window and confirm the value has no trailing backslash and points to the JDK root. After any change, close and reopen the terminal and the IDE.
Frequently Asked Questions
Do I need the JDK or just the JRE?
For development, install the JDK. The JRE only runs compiled Java programs and cannot compile source code.
Which JDK version should I install?
Install the current long-term support (LTS) release unless a project requires a specific version. Check your project's documentation for its required Java version.
Is JAVA_HOME required?
Not for running java from a terminal, but many build tools and IDEs expect it. Setting it avoids problems later.
Can I install more than one JDK?
Yes. Install each version into its own folder and change JAVA_HOME or your IDE's SDK setting to switch between them.
Why does javac say it is not recognized?
Either you installed the JRE instead of the JDK, or the JDK's bin folder is not in PATH. Re-check the install type and the Path variable.
Do I need to restart Windows after installing the JDK?
No. Opening a new terminal is enough to pick up environment changes.