Install Java's JDK and set JAVA_HOME on Windows |Video upload date:  · Duration: PT5M47S  · Language: EN

Step by step guide to install Java JDK on Windows and set JAVA_HOME so build tools and IDEs can find the correct Java

So you want Java on Windows and not a single mysterious build error. Good choice. This guide walks you through downloading a JDK, installing it, and setting the JAVA_HOME environment variable so your IDE and build tools stop whispering about missing Java.

Quick checklist before you begin

  • Decide OpenJDK or Oracle JDK. Both work for most projects.
  • Choose a long term support release like 17 or 21 for stability.
  • Pick the x64 MSI installer for the smoothest Windows experience.
  • Make a mental note to run the installer as a mildly responsible adult.

Download and install the JDK

Head to the OpenJDK build page or Oracle Java download page and get the x64 MSI for the LTS version you prefer. Run the MSI and accept defaults unless you enjoy having confusing folder layouts. The installer will show the installation path near the end. Write that path down or screenshot it like you own a phone.

Typical example path is C:\Program Files\Java\jdk-17 or C:\Program Files\Java\jdk-21. You will need that exact folder in the next step so do not guess.

Set JAVA_HOME and update PATH

Windows likes environment variables and you will set JAVA_HOME so every IDE and build tool can find the correct JDK. You can do this with the GUI or from the command line if you enjoy keyboard workouts.

GUI method

  1. Open Start and search for Edit the system environment variables.
  2. Click Environment Variables in the System Properties dialog.
  3. Under User or System variables click New to add JAVA_HOME and paste the JDK installation folder path you noted earlier.
  4. Edit the PATH variable and add %JAVA_HOME%\bin at the front so this JDK is used first.
  5. Click OK to save and close everything. Yes, you must open a new terminal for changes to take effect.

Command line option

If you prefer not to touch the GUI use setx for a quick job. For a user variable run:

setx JAVA_HOME "C:\Program Files\Java\jdk-17"

To add the bin folder to your user PATH you can run:

setx PATH "%PATH%;%JAVA_HOME%\bin"

Warning do not blindly run PATH edits without understanding them. Back up your PATH if you like avoiding small tragedies.

Verify the installation

Open a new Command Prompt window so the new environment variables load. Then run:

java -version
javac -version

Both commands should report the same major version number. If they match congratulations your JDK and JAVA_HOME are speaking the same language and your build tools will stop nagging.

Multiple JDKs and project switching

If you need more than one JDK for different projects do not edit system variables every time like it is 2003. Use one of these approaches instead

  • Project scripts that set JAVA_HOME and PATH for a terminal session when you start work.
  • Use a version manager inside Windows Subsystem for Linux for cleaner switching if you use WSL.
  • Tools and wrappers such as Jabba or other Java version managers can help on native Windows as well.

Final notes

Pick LTS releases if you want fewer surprises. Keep the JDK path exact and put %JAVA_HOME%\bin first in PATH to make sure the one you installed is the one the command line uses. And if anything breaks remember you can always reinstall and blame cache issues.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.