How to Set Java Path in Windows 10/11 [Step-by-Step Guide]

How to Set Java Path

If you’re starting with Java development on Windows, one of the first things you must learn is how to set Java path properly. Without configuring the path, your system might not recognize Java commands like javac or java.

In this guide, I’ll show you step by step how to set Java path in Windows 10 and Windows 11. Follow along to avoid common mistakes.

Why Do You Need to Set Java Path?

Setting the Java path allows your system to locate Java Development Kit (JDK) executables from any directory in the Command Prompt. This is essential for compiling and running Java programs.

Without the Java path, you might see errors like:

'javac' is not recognized as an internal or external command.

Step 1: Download and Install Java JDK

Go to the official Oracle website and download the latest version of Java JDK suitable for your Windows version. Run the installer and follow the on-screen instructions.

👉 Example Installation Path:

C:\Program Files\Java\jdk-21
How to Set Java Path

Step 2: Locate Java Installation Directory

After installation:

Open File Explorer, navigate to where Java is installed (usually in Program Files → Java)

Example Path:

C:\Program Files\Java\jdk-21
How to Set Java Path

You’ll need this path in the next steps.

Step 3: Setting JAVA_HOME Environment Variable

  • Right-click on This PC or My Computer → Click Properties
  • Click Advanced system settings
  • Under the Advanced tab → Click Environment Variables
  • Click New… under System Variables
  • Variable Name:
JAVA_HOME
  • Variable Value: Paste your Java JDK installation path
C:\Program Files\Java\jdk-21
  • 👉 Click OK.
How to Set java Path

Step 4: Updating PATH Variable

  • In the Environment Variables window, under System Variables, find Path → Click Edit
  • Click New → Add the following:
%JAVA_HOME%\bin
  • Click OK on all windows to apply changes.
How to Set Java Path

Step 5: Verify Java Path Setup

Open Command Prompt (CMD) and type:

java -version

and

javac -version

✅ If properly configured, it will show the installed Java version.

How to Set Java Path

Common Errors When Setting Java Path

  • Incorrect JAVA_HOME path → Double-check for typos
  • Path variable missing %JAVA_HOME%\bin → Ensure it’s added correctly
  • Forgot to restart CMD → Restart Command Prompt after changes

Final Thoughts on Setting Java Path

Now you know how to set Java path in Windows 10/11 the correct way. Setting the Java path is essential for every Java developer, especially if you work with IDEs like Eclipse or IntelliJ IDEA or build tools like Maven or Gradle.

Follow the steps carefully, and you’ll never face path-related issues again.