If you’ve installed Java on your Windows 11 PC but still see an error like 'java' is not recognized as an internal or external command
when you try to run it in Command Prompt, it means Windows doesn’t know where to find Java. The fix? You need to add Java to your system’s PATH environment variable.
Adding Java to PATH tells Windows where the java.exe and javac.exe files are located, allowing you to run Java commands from any directory without typing the full file path.
In this step-by-step guide, we’ll show you how to add Java to PATH manually and verify that it works correctly — so you can compile and run Java programs smoothly.
What Does Adding Java to PATH Mean?
When you type a command like java or javac in Command Prompt, Windows searches for it in a list of directories defined in the PATH environment variable.
If Java’s installation folder isn’t included in PATH, Windows won’t recognize the command.
By adding Java’s “bin” folder (where all executable files are stored) to PATH, you make it accessible system-wide — so any terminal or IDE can use it instantly.
Step 1: Find Your Java Installation Path
Before editing the PATH variable, you need to know where Java is installed.
- Press Windows + S, type File Explorer, and open it.
- Navigate to one of these default Java installation folders:
C:\Program Files\Java\jdk-25\binC:\Program Files (x86)\Java\jdk-25\bin
jdk-21orjdk-17.) - Copy the full path of the bin folder — for example:
C:\Program Files\Java\jdk-25\bin
This path is what we’ll add to the PATH environment variable next.
Step 2: Open Environment Variables
Now it’s time to access your system’s environment settings.
- Press Windows + R, type
sysdm.cpl, and press Enter. - In the System Properties window, go to the Advanced tab.
- Click on Environment Variables at the bottom.
This opens a list of all system and user-level variables, including PATH.
Step 3: Add Java to the PATH Variable
- Under the System Variables section, scroll down and select Path.
- Click Edit → then click New.
- Paste your Java “bin” directory path (for example):
C:\Program Files\Java\jdk-25\bin - Click OK on all windows to save the changes.
This adds Java to your PATH, allowing the system to locate its executables from anywhere.
Step 4: Verify the PATH Configuration
To confirm everything’s working:
- Press Windows + S, type cmd, and click Run as Administrator.
- Type the following command and hit Enter:
java -version - You should see something like this:
java version "25.0.1"Java(TM) SE Runtime Environment (build 25.0.1+11-LTS)Java HotSpot(TM) 64-Bit Server VM (build 25.0.1+11-LTS, mixed mode)
If the version number appears, congratulations — you’ve successfully added Java to PATH!
How to Add JAVA_HOME Environment Variable
Adding JAVA_HOME is useful for development tools like IntelliJ IDEA, Eclipse, or Maven.
- Open Environment Variables again.
- Click New under System Variables.
- Set the Variable name to
JAVA_HOME. - For Variable value, paste your Java JDK folder path (without
\bin):C:\Program Files\Java\jdk-25 - Click OK, then restart your PC.
Now you can reference Java easily in scripts or software that relies on JAVA_HOME.
Why Adding Java to PATH Matters
Adding Java to PATH makes development and troubleshooting easier. It allows you to:
- Run Java commands from any directory.
- Compile Java programs directly using
javac. - Use build tools like Maven or Gradle without manual path setup.
- Avoid frustrating “command not found” errors.
It’s a simple one-time setup that saves you time for every future Java project.
Final Thoughts
And that’s it! You’ve successfully added Java to the PATH in Windows 11. Whether you’re compiling code, using command-line tools, or setting up your first Java project, this setup ensures Windows can find and execute Java properly.
If you plan to upgrade or install a new JDK version in the future, don’t forget to update the PATH variable accordingly — especially if the folder name changes (like from jdk-21 to jdk-25). Once done, you’re ready to start coding in Java without any system errors getting in your way.