How to Set Up Java on Windows Without Losing Your Mind

How to Set Up Java on Windows Without Losing Your Mind

⚙️ Setting Up Java Environment Variables on Windows

Something I discovered: even if you don’t configure the Java environment variable, Eclipse still works. But if you want to use javac or other tools in the console, you definitely need them set up...

This article is for those using Windows who realized a bit late that they hadn’t configured their environment variables and now Java doesn’t work in the command line.


🧭 Let’s Get Started!

1. Open File Explorer

Go to This PC, then click on System Properties at the top.

Step 1: Open system properties


2. Open Advanced System Settings

Inside the system properties, click on Advanced system settings.

Step 2: Advanced system settings


3. Open Environment Variables

A popup titled System Properties will appear. At the bottom, click on Environment Variables.

Step 3: Environment variables


4. Create New User Variables

In the Environment Variables popup, you’ll have the option to add variables either for the system or just for your user account. Choose User variables and click New.

Step 4: Add a new user variable


5. Add JAVA_HOME and PATH

You'll now see a New User Variable popup. We’ll go through this process twice: once for the JAVA_HOME variable and once for the PATH. Step 5:New User Variable


JAVA_HOME

  • Variable name: JAVA_HOME
  • Variable value: The path to your JDK installation (example):
C:\Program Files\Java\jdk-17

PATH

PATH

  • Variable name: PATH
  • Variable value: Add this string to include your JDK's bin folder:
C:\WINDOWS;C:\WINDOWS\system32;%JAVA_HOME%\bin

If PATH already exists, edit it instead of creating a new one, and just append ;%JAVA_HOME%\bin.


✅ Test the Configuration

Once everything is set, click OK on all the popups to save.

Then, open your preferred terminal: cmd, PowerShell, or Command Prompt, and run:

java -version

If it returns your Java version, your setup is working correctly!


🫡 That’s It!

Until next time 🙌