How to Check the Version of Java on Any System
Knowing which version of Java is installed on your machine matters more than most people realize. Whether you're running a Java-based application, troubleshooting a compatibility error, or setting up a development environment, the version number is often the first thing you need to confirm. Fortunately, checking it is straightforward — once you know where to look.
Why Java Version Numbers Matter
Java has a long release history, and different versions aren't always interchangeable. Some applications require a minimum Java version to run correctly. Others were built against older versions and may break on newer ones. The Java Runtime Environment (JRE) is what most end users need to run Java applications, while developers typically work with the Java Development Kit (JDK), which includes the JRE plus compilers and tools.
Java versioning also shifted naming conventions over time. Older releases used names like Java 1.8 (commonly known as Java 8). Starting with Java 9, Oracle moved to a more straightforward numbering scheme — Java 11, Java 17, Java 21, and so on. You may see both formats in output depending on the version installed.
How to Check Java Version on Windows 💻
The fastest method on Windows is through the Command Prompt:
- Press
Windows + R, typecmd, and hit Enter - In the Command Prompt window, type:
java -version - Press Enter
You'll see output similar to:
java version "17.0.8" 2023-07-18 Java(TM) SE Runtime Environment (build 17.0.8+9-LTS) Java HotSpot(TM) 64-Bit Server VM (build 17.0.8+9-LTS, mixed mode) The first line tells you everything you need — the major version number, the minor update, and the build date.
If you're working with a JDK specifically and want to confirm the compiler version, you can also run:
javac -version This returns the compiler version, which should match your JDK installation.
Alternative on Windows: You can also check via Control Panel → Programs → Java if Java's control panel applet is installed, though this method isn't always available on newer installations and shows less detail.
How to Check Java Version on macOS
On macOS, open Terminal (found in Applications → Utilities) and run the same command:
java -version The output format is identical to Windows. macOS no longer bundles Java by default, so if Java isn't installed, you'll see a prompt to install it or an error message rather than a version number.
If you have multiple Java versions installed — which is common for developers using tools like SDKMAN or Homebrew — you can list all installed versions with:
/usr/libexec/java_home -V This command is macOS-specific and shows every JDK installed on the system along with their paths.
How to Check Java Version on Linux
On any Linux distribution, open a terminal and run:
java -version Or for more detailed output:
java -version 2>&1 Linux systems often have multiple Java versions installed side by side, managed through tools like update-alternatives. To see all installed versions and which one is currently active, run:
update-alternatives --list java This is particularly useful on Ubuntu, Debian, and other Debian-based distributions. On Fedora or RHEL-based systems, the equivalent is typically managed through alternatives --config java.
Understanding the Output 🔍
| Output Element | What It Means |
|---|---|
java version "17.0.8" | Major version 17, update 8 |
openjdk version "21.0.1" | OpenJDK build (open-source distribution) |
Java(TM) SE Runtime Environment | Oracle's official JRE |
64-Bit Server VM | Confirms 64-bit architecture |
build 17.0.8+9-LTS | LTS = Long-Term Support release |
LTS versions (like Java 8, 11, 17, and 21) receive extended security and bug fix updates. Non-LTS versions have shorter support windows, which matters if you're running Java in a production or long-term environment.
What If Java Isn't Found?
If running java -version returns an error like 'java' is not recognized or command not found, Java either isn't installed or isn't added to your system's PATH environment variable.
On Windows, Java's installer typically adds itself to PATH automatically — but not always, especially with JDK-only installs. You may need to manually add the Java bin directory to your PATH settings under System Properties → Environment Variables.
On Linux and macOS, if you installed Java through a package manager, running sudo apt install default-jdk (Debian/Ubuntu) or brew install openjdk (macOS) and following the post-install instructions usually resolves PATH issues.
Variables That Affect What You'll See
Checking your Java version sounds simple, but the results depend on several factors:
- Which Java distribution is installed — Oracle JDK, OpenJDK, Amazon Corretto, Eclipse Temurin, and others all report slightly differently
- Whether multiple versions are installed — the
java -versioncommand shows only the active version, not all installed ones - Your operating system and package manager — how Java was installed affects where it lives and how it's managed
- JRE vs JDK — running applications only requires the JRE; development work requires the full JDK, and both can coexist
A developer running a build tool like Maven or Gradle may also need to check the JAVA_HOME environment variable, since some tools read from that directly rather than the system PATH. Running echo $JAVA_HOME (Mac/Linux) or echo %JAVA_HOME% (Windows Command Prompt) shows which Java installation those tools will use — which may differ from what java -version reports. 🖥️
What that means in practice depends entirely on your setup — how Java was installed, whether you're developing or just running applications, and whether any tools on your system have their own Java preferences configured independently.