How to Check Your Java Version

Run java -version in a terminal (Command Prompt, PowerShell, Terminal.app, or a Linux shell). That single command shows the installed Java version on any operating system.

The command

java -version

Note the single dash — java --version (double dash) also works on Java 11+ but prints a different format.

Reading the output

openjdk version "21.0.2" 2024-01-16
OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13)
OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13, mixed mode, sharing)
  • First number (21) is the major version — what frameworks and libraries care about.
  • Second number (0.2) is the minor/patch update within that major version.
  • Temurin tells you it is the Eclipse Temurin distribution of OpenJDK.

Legacy version numbering (Java 8 and below)

java version "1.8.0_401"

Java 8 and older used 1.x notation: 1.8 = Java 8, 1.7 = Java 7. Anything starting with 1. is Java 8 or older.

Check the compiler version

javac -version

If java -version works but javac -version fails with "not found", you have a JRE (runtime only), not a JDK. Reinstall with the full JDK package.

Check which java binary is active

Windows:

where java

macOS / Linux:

which java
readlink -f $(which java)   # resolve symlinks to the actual binary

List all installed JDKs

macOS:

/usr/libexec/java_home -V

Linux (Debian/Ubuntu):

update-alternatives --display java

Linux (Arch):

archlinux-java status

Windows: Open Settings > Apps > Installed apps and search "JDK", or run:

winget list | findstr JDK

Check Java version inside a running application

System.out.println(System.getProperty("java.version"));
System.out.println(Runtime.version());         // Java 9+

This prints the JVM version the application is actually running on, which may differ from the system default if the app was launched with a specific JVM path.