Setting the Path for Java on Windows

Assuming Java is installed in C:\Program Files\java\jdk directory

Step-by-step Instructions:​

  1. Open System Properties:
    • Right-click on This PC or My Computer on your desktop or in File Explorer.
    • Select Properties.
  2. Open Advanced System Settings:
    • Click on Advanced system settings on the left sidebar.
    • This opens the System Properties window on the Advanced tab.
  3. Environment Variables:
    • Click on the Environment Variables button near the bottom.
  4. Edit the Path Variable:
    • In the System variables section (or User variables if you want to set it for just your user), scroll and find the variable named Path.
    • Select Path and click Edit.
  5. Add the Java JDK bin Path:
    • If you are on Windows 10 or later, you'll see a list of paths. Click New and add:


      C:\Program Files\java\jdk\bin
      (Make sure this path exactly matches your Java installation directory)
    • If you see a single line with paths separated by semicolons (on older Windows):
      • Carefully append the Java path to the end, separated by a semicolon:


        C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin
      • Do not delete the existing entries.
  6. Save and Close:
    • Click OK on all open dialogs to save changes.
  7. Restart Command Prompt:
    • Close any open Command Prompt windows and open a new one to reload the PATH settings.

Verify the Setup​

  1. Open Command Prompt.
  2. Run:


    javac -version
  3. You should see the version of the Java compiler printed, confirming Java is correctly added to your PATH.
Note: If your installation path contains spaces (like Program Files), the system handles it fine in the PATH variable as long as you add the full path without extra quotes.