How to Check the Java Version in CMD (Command Prompt Guide)

Knowing which version of Java is installed on your machine isn't just a housekeeping detail — it directly affects whether your applications run correctly, whether security patches are current, and whether your development environment is configured the way you think it is. Checking the Java version through the Windows Command Prompt (CMD) takes seconds, but understanding what the output actually tells you is where things get more nuanced.

Why Checking Your Java Version Matters

Java isn't a single, static tool. It has evolved through dozens of major releases — from Java 8 (still widely used in enterprise environments) through Java 11, 17, and beyond. Different applications, frameworks, and build tools have different Java requirements. A web app scaffolded with Spring Boot may need Java 17, while legacy enterprise software might be locked to Java 8. Running the wrong version silently can cause build failures, cryptic runtime errors, or security gaps.

Beyond compatibility, Java licensing and support timelines vary between versions. Oracle's JDK has different licensing terms than OpenJDK distributions like Amazon Corretto, Eclipse Temurin, or Microsoft's build of OpenJDK. Knowing what's installed helps you confirm whether you're running a supported, appropriate distribution.

How to Check the Java Version in CMD 🖥️

The Basic Command

Open Command Prompt (press Win + R, type cmd, hit Enter), then run:

A typical output looks like:

Breaking down what you're reading:

Output ComponentWhat It Means
java version "17.0.9"Major version (17) and update number (0.9)
Java SE Runtime EnvironmentConfirms it's the JRE (runtime), not just JDK tools
HotSpot 64-Bit Server VMThe JVM variant and architecture
LTSLong-Term Support designation

Checking the Java Compiler Version (JDK)

If you're a developer and need to confirm the Java Development Kit (JDK) — not just the runtime — run:

Output example:

If this command returns an error like 'javac' is not recognized, it means either the JDK isn't installed (only the JRE is), or the JDK's bin directory isn't in your system's PATH environment variable.

Checking the Full Java Version String

For more detailed version metadata, use:

This returns a compact single-line string that's useful when copying version info for bug reports or configuration files.

What the Version Numbers Actually Mean

Java version numbering changed significantly with Java 9. Before that, versions were labeled as 1.8, 1.7, etc. — so java version "1.8.0_391" means Java 8. From Java 9 onward, Oracle adopted a cleaner format: 9, 10, 11, and so on.

Key version milestones to know:

  • Java 8 (1.8) — Still prevalent in legacy systems; long LTS history under Oracle
  • Java 11 — First LTS version under the new versioning scheme; widely adopted
  • Java 17 — Current mainstream LTS for most modern frameworks
  • Java 21 — The most recent LTS release as of late 2023

LTS (Long-Term Support) versions receive extended security and bug-fix updates, making them the preferred choice for production environments over short-term feature releases.

When CMD Says Java Isn't Recognized

If running java -version returns:

There are a few possible causes:

  • Java isn't installed — download a JDK or JRE from a trusted source
  • JAVA_HOME isn't set — the environment variable pointing to your Java installation directory may be missing
  • PATH isn't configured — the bin folder inside your Java install directory needs to be in your system PATH

You can verify where Java is installed by running:

This lists every java.exe found in your PATH. If multiple entries appear, the first one is what gets executed by default — a common source of version confusion on machines with multiple Java installs.

Multiple Java Versions on One Machine

Developers frequently work with multiple Java versions simultaneously. Tools like SDKMAN! (more common on Unix-based systems) or manual PATH switching on Windows let you control which version is active in any given session.

On Windows, you can check which Java installation is being used by running:

or by inspecting the JAVA_HOME environment variable:

The version that CMD reports depends entirely on which installation your PATH variable prioritizes — not necessarily the most recent one on your system. 🔍

Variables That Affect What You'll Find

Several factors shape what java -version actually tells you in practice:

  • Operating system configuration — How PATH and JAVA_HOME are set up at the system vs. user level
  • Number of Java installs — Multiple JDKs create ordering ambiguity
  • JDK vs. JRE — Some environments only install the runtime, not the full development kit
  • Distribution — Oracle JDK, OpenJDK, Corretto, Temurin, and Zulu all report slightly differently in the version string
  • IDE or build tool overrides — Maven, Gradle, and IDEs like IntelliJ IDEA may use a bundled or separately configured Java version independent of what CMD reports

What CMD shows you is the Java version your terminal session will use for running scripts, compiling code, or launching tools. Whether that version matches what your IDE, CI/CD pipeline, or production server is using is a separate question — and one that often catches developers off guard.