World’s largest virtual agentic engineering & quality conference
Learn how to easily install Java on Windows. This blog covers steps for both developers and casual users, troubleshooting tips, and more.

Yatish Jhamb
Author
Published on: January 21, 2025
Last Updated on: January 24, 2025
Java is a widely used programming language for developing software applications across various platforms. Installing Java is a fundamental step for developers to set up their development environment.
This blog will guide you through the process to install Java on Windows: choosing a JDK, running the installer, verifying the install from the Command Prompt, configuring the JAVA_HOME and Path environment variables, and removing older versions that can conflict with the new one.
Before downloading anything, there is one decision to make. You need the JDK (Java Development Kit), not just the JRE, because the JDK includes the compiler (javac) along with the runtime. If you only intend to run Java applications rather than write them, a runtime is enough, but almost everyone reading a guide like this wants the JDK.
The JDK itself comes in two flavours, and the difference is licensing rather than the language:
For the vast majority of developers, either works and your code behaves identically. Pick an OpenJDK build if you want to avoid licensing questions entirely, and Oracle JDK if your organisation wants Oracle’s commercial support.
On version, choose an LTS (Long Term Support) release rather than the newest number available. Java 21 is the current LTS most projects standardise on, and LTS releases receive updates for years, whereas non-LTS releases are superseded within six months. The steps below are the same whichever you pick.
Let’s walk through the steps to install and set up Java on your system. For demonstration, we’ll install Java on Windows:




Before configuring anything, check what Windows can already see. Open the Command Prompt by pressing Win + R, typing cmd.exe, and pressing Enter (searching for “Command Prompt” in the Start menu works too). Then run these two commands:
java -version
javac -versionIf the installation succeeded and Windows can find Java, you will see output similar to this:
java version "21.0.2" 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 21.0.2+13-LTS-58)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.2+13-LTS-58, mixed mode, sharing)
javac 21.0.2The two commands test different things, which is why both matter. java -version reports the runtime, so it confirms you can run Java programs. javac -version reports the compiler, so it confirms you have a full JDK rather than just a runtime, and that the compiler is on your Path.
A common outcome is that java -version works while javac -version returns ‘javac’ is not recognized as an internal or external command. That is not a broken installation. It means the JDK’s bin directory is not on your Path, which the next section fixes. If neither command is recognised, open a new Command Prompt first, since an already-open window will not pick up environment changes.
Two variables matter here. JAVA_HOME points at the JDK folder itself and is what build tools like Maven, Gradle, and many IDEs read to locate Java. Path is what lets you type java or javac in any Command Prompt without giving the full path. Set JAVA_HOME first, then reference it from Path, so that upgrading Java later means changing one value instead of hunting through your Path.
Let’s look at the steps to setup environment variables for Java installation on Windows:





You can also confirm the variable itself resolved correctly by running:
echo %JAVA_HOME%If that prints your JDK path, JAVA_HOME is set. If it prints the literal text %JAVA_HOME%, the variable does not exist in that session, so re-check the spelling and open a fresh Command Prompt.
Old Java installations are the usual cause of the confusing situation where java -version reports a version you did not install. Windows resolves java using the first matching entry in Path, so a leftover older install sitting earlier in the list quietly wins, no matter what JAVA_HOME says. Removing versions you no longer need also closes off known vulnerabilities in unpatched runtimes.
To remove an older version safely:
Keeping several versions side by side is legitimate if different projects need different releases. In that case, leave them installed and switch between them by changing JAVA_HOME rather than uninstalling.
Installing Java on Windows is important for developers who depend on Java-based software applications. Once configured, you can easily execute Java-powered products or create Java-based software applications.
Author
Yatish Jhamb is a Community Contributor at TestMu AI, where he creates content on software testing, CI/CD, AI, and test automation. He holds certifications in Selenium, Appium, Playwright, Cypress, and KaneAI, and has contributed to technical blogs, SEO-focused tool pages, and video scripts for the QA community. His work bridges technical accuracy with clear, accessible content for testers and developers.
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance