Setting the Path for Java on Windows
Assuming Java is installed in C:\Program Files\java\jdk directory
Step-by-step Instructions:
- Open System Properties:
- Right-click on This PC or My Computer on your desktop or in File Explorer.
- Select Properties.
- Open Advanced System Settings:
- Click on Advanced system settings on the left sidebar.
- This opens the System Properties window on the Advanced tab.
- Environment Variables:
- Click on the Environment Variables button near the bottom.
- 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.
- 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.
- Carefully append the Java path to the end, separated by a semicolon:
- If you are on Windows 10 or later, you'll see a list of paths. Click New and add:
- Save and Close:
- Click OK on all open dialogs to save changes.
- Restart Command Prompt:
- Close any open Command Prompt windows and open a new one to reload the PATH settings.
Verify the Setup
- Open Command Prompt.
- Run:
javac -version - You should see the version of the Java compiler printed, confirming Java is correctly added to your PATH.