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.
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.
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.
JAVA_HOME
and paste the JDK installation folder path you noted earlier.%JAVA_HOME%\bin
at the front so this JDK is used first.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.
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.
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
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.