How to Check Your Java Version in Command Prompt
Knowing which version of Java is installed on your machine isn't just a housekeeping task — it directly affects whether your applications run, whether your development environment compiles correctly, and whether you're exposed to known security vulnerabilities. The good news: checking your Java version takes a single command. The nuance is in understanding what that output actually tells you.
Why Your Java Version Matters
Java isn't one monolithic thing. There's the JRE (Java Runtime Environment), which lets you run Java applications, and the JDK (Java Development Kit), which lets you build and compile them. You may have one, both, or multiple versions of each installed simultaneously.
Version numbers also carry real meaning. Java follows a release cadence where major versions (Java 8, 11, 17, 21) are designated LTS (Long-Term Support) releases, meaning they receive extended security patches. Non-LTS versions have much shorter support windows. If you're working on a project that specifies Java 11 compatibility, running Java 21 doesn't automatically mean you're safe — some behaviors and APIs differ.
The Basic Command: java -version
Open Command Prompt on Windows (search for cmd in the Start menu) and type:
A typical output looks like this:
Here's what each line tells you:
- Line 1 — The major version (17), the minor update (.0), and the patch release (.9). "LTS" confirms it's a long-term support build.
- Line 2 — The specific build number and the runtime environment type (Oracle SE, OpenJDK, Amazon Corretto, etc.).
- Line 3 — The JVM (Java Virtual Machine) variant and whether it's running in 64-bit or 32-bit mode.
Checking the JDK Version Specifically
If you're a developer, you'll also want to confirm your compiler version, not just your runtime:
This returns something like:
If java -version works but javac -version throws an error like 'javac' is not recognized, that means you have the JRE installed but not the JDK. You can run Java programs, but you can't compile them.
What "Not Recognized" Actually Means 🔍
If you run java -version and get:
Java either isn't installed, or it's installed but not added to your system's PATH environment variable. PATH is a list of directories Windows checks when you type a command — if Java's bin folder isn't on that list, Command Prompt can't find it even if Java exists on your drive.
To diagnose this further, you can check the default installation location directly:
Adjust the path to match your installed version. If this works but java -version doesn't, the issue is PATH configuration, not the installation itself.
Multiple Java Versions on One Machine
This is where things get more complex. Developers often install multiple Java versions to support different projects — a legacy application might require Java 8, while a newer microservice targets Java 21. Tools like SDKMAN (on Linux/macOS) or manually managed environment variables on Windows handle this.
On Windows, the version that java -version reports depends on which path appears first in your PATH variable. You might have Java 21 installed but still see Java 8 in Command Prompt because an older entry takes priority.
To see all Java versions registered on a Windows system, you can check:
This lists every java.exe path found in your PATH. Each entry corresponds to a different installation.
Understanding the Version Number Format
| Format Example | What It Means |
|---|---|
| java version "1.8.0_391" | Java 8 (legacy naming — "1.8" = Java 8) |
| java version "11.0.21" | Java 11, update 21 |
| java version "17.0.9" | Java 17, patch release 9 |
| java version "21.0.1" | Java 21, patch release 1 |
Java 8 and earlier used the 1.x naming convention. From Java 9 onward, Oracle switched to a cleaner major.minor.patch format. If you see 1.8, that's Java 8 — not a lower version than Java 11.
Variables That Affect What You'll See
Several factors determine which version appears when you run the command:
- Operating system architecture — 32-bit vs. 64-bit installations behave differently and may be located in different program directories (Program Files vs. Program Files (x86))
- Java distribution — Oracle JDK, OpenJDK, Amazon Corretto, Microsoft Build of OpenJDK, and Eclipse Temurin all produce valid Java installations with slightly different build strings
- PATH order — On machines with multiple installations, whichever bin folder is listed first in PATH wins
- IDE-managed JDKs — Tools like IntelliJ IDEA or Eclipse often bundle their own JDK, separate from what Command Prompt sees
💡 The Layer Worth Paying Attention To
The command output is reliable — but it only tells you what Command Prompt sees. Your IDE, your build tool (Maven, Gradle), and your deployment environment may each be pointing to a completely different Java installation.
A developer might verify Java 17 in Command Prompt, but their Maven build still compiles against Java 8 because of settings in the pom.xml or a JAVA_HOME environment variable pointing elsewhere. Checking the version is step one — but which Java instance actually runs your code depends on your full environment configuration, and that varies considerably from one setup to the next.