Check Java Version on Mac
How to check Java version on Mac with java -version in terminal. Find your JDK location, list all installed Java versions, and solve macOS Java problems.
Before installing Java, it's wise to check if it's already installed.
Plus you might need to know which Java version is installed on your Mac if you're installing Java-dependent software or troubleshooting an application. This guide shows you how to check your Java version, understand what the output means, and verify your complete Java installation.
You'll use a terminal application to find your current Java version, determine whether you have the developer JDK or the consumer JRE, and list all Java installations on your system. If something looks wrong, the troubleshooting section will help you fix common issues.
Before you get started
You'll need a terminal application to check your Java version. Apple includes the Mac terminal but I prefer Warp Terminal. Warp is an easy-to-use terminal application, with AI assistance to help you learn and remember terminal commands. Download Warp Terminal now; it's FREE and makes coding easier when working with Java.
Check the Java version
The java -version command is the standard way to check your Java version. This works on every Mac with Java installed. Starting with Java 11, you can also use the double-dash syntax java --version. Either command produces similar output.
Learn How to Open Terminal in Mac and run:
$ java -version
If you see an error like java: command not found or this error:
$ java --version
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
you'll need to read on.
What to do next
- If you think you have Java installed and don't see it, see the article Unable to Locate a Java Runtime
- If you need to install Java, jump directly to Brew Install Java - Easy Cask Method if you are using Homebrew already
- If you need to install Java, and don't want to use Homebrew, see Download Java for Mac for a manual installation
The help message says "please visit http://www.java.com" BUT don't visit Oracle's java.com to download Java! It's intended for consumers who need the Java 8 JRE consumer download and sends developers to Oracle's Java web pages. For developers, Java is open source and available for free from many vendors. Oracle owns the trademark and wants to sell enterprise licenses of the Oracle JDK distribution. Stick to free versions unless you're working for a company that already has a paid Oracle Java licensing arrangement.
If Java is installed
If Java is installed, you'll see output like this (Eclipse Temurin example):
$ java -version
openjdk version "25.0.1" 2025-10-21 LTS
OpenJDK Runtime Environment Temurin-25.0.1+12 (build 25.0.1+12-LTS)
OpenJDK 64-Bit Server VM Temurin-25.0.1+12 (build 25.0.1+12-LTS, mixed mode, sharing)
Or like this (Oracle JDK example):
$ java -version
java version "25.0.1" 2025-10-21 LTS
Java(TM) SE Runtime Environment (build 25.0.1+12-LTS-29)
Java HotSpot(TM) 64-Bit Server VM (build 25.0.1+12-LTS-29, mixed mode)
The output shows Java is installed. Here's what it tells you.
Understand the version output
The java -version command displays three lines of information.
Line 1 — Version number and release date:
openjdk version "25.0.1" 2025-10-21 LTS
This shows the Java version (25.0.1), the release date (October 21, 2025), and whether it's an LTS (Long-Term Support) release. The word openjdk indicates an OpenJDK distribution; Oracle JDK shows java version instead.
Line 2 — Runtime environment:
OpenJDK Runtime Environment Temurin-25.0.1+12 (build 25.0.1+12-LTS)
This identifies the vendor (Temurin, Corretto, Zulu, or Oracle) and the build number. The +12 after the version means build 12.
Line 3 — Virtual machine:
OpenJDK 64-Bit Server VM Temurin-25.0.1+12 (build 25.0.1+12-LTS, mixed mode, sharing)
This shows the Java virtual machine (JVM) type. The Java virtual machine is the software that allows Java applications to "write once, run anywhere" on macOS, Windows, or Linux. "Mixed mode" means the JVM uses both interpretation and JIT (Just-In-Time) compilation. "Sharing" indicates class data sharing is enabled for faster startup.
Identify your Java distribution
Different Java distributions show different vendor strings. Here's how to recognize them:
Temurin– Eclipse Temurin (recommended for most developers)Corretto– Amazon Corretto (optimized for AWS)Zulu– Azul Zulu (OpenJDK with enterprise support contracts)Liberica– BellSoft Liberica (default in Spring Boot)Java(TM),HotSpot(TM)– Oracle JDK (only use it if your company has a license for commercial use)
Take a look at whichjdk.com for detailed (and opinionated) comparisons.
Understand version numbers
Java version numbers follow different formats depending on the major version.
Modern format (Java 9 and later):
The version 25.0.1+12 breaks down as:
- 25 — Major version (Java 25)
- 0 — Minor version (typically 0 for new releases)
- 1 — Security patch level
- +12 — Build number
Legacy format (Java 8 and earlier):
The version 1.8.0_392 breaks down as:
- 1.8 — Indicates Java 8
- 0 — Always 0
- _392 — Update number
When using commands like /usr/libexec/java_home -v, use 1.8 for Java 8, not just 8.
Check if the JDK is installed
The Java Development Kit (JDK) includes everything developers need: the Java compiler, debugger, and other tools. The Java Runtime Environment (JRE) only runs Java programs—it cannot compile them.
To check if you have the JDK, run:
$ javac -version
If the JDK is installed, you'll see output like:
$ javac -version
javac 25.0.1
If you get "command not found," you only have the JRE (or no Java at all). Developers need the JDK for compiling source code.
JRE vs JDK explained
Starting with Java 11, Oracle stopped releasing standalone JREs. Modern Java installations are full JDKs, so if you installed Java recently, you almost certainly have the JDK.
JRE (Java Runtime Environment):
- Runs Java applications
- Includes the
javacommand - Does not include compiler or development tools
- Standalone JRE downloads discontinued after Java 8
JDK (Java Development Kit):
- Complete development toolkit
- Includes everything in the JRE plus
javac(compiler),jar,jdb(debugger), andjshell - Required for Java development
- What you get with modern Java installations
If you're a developer, you'll use a JDK.
Additional JDK verification
You can also verify JDK installation with these commands:
$ which javac
$ jshell --version
If which javac returns a path, the JDK is installed. The jshell command (available since Java 9) is another JDK-only tool.
List all installed Java versions
Your Mac can have multiple Java versions installed simultaneously. The /usr/libexec/java_home utility—a macOS-specific tool—manages all your Java installations.
To list every Java version on your system, run:
$ /usr/libexec/java_home -V
Note the capital V. The output looks like this:
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
25.0.1 (arm64) "Eclipse Adoptium" - "OpenJDK 25.0.1" /Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home
21.0.3 (arm64) "Eclipse Adoptium" - "OpenJDK 21.0.3" /Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home
1.8.0_392 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_392.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home
Each line shows: version, architecture (arm64 for Apple Silicon, x86_64 for Intel), vendor, name, and installation path. The last line indicates the default Java home.
Get the path for a specific version
To find the installation path for a particular Java version:
$ /usr/libexec/java_home -v 25
This returns something like:
$ /usr/libexec/java_home -v 25
/Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home
For Java 8, use the legacy version format $ /usr/libexec/java_home -v 1.8.
You'll need to know the Java location to Set JAVA_HOME on Mac.
Run a command with a specific Java version
The --exec flag lets you run a command with a specific Java version without changing your environment:
$ /usr/libexec/java_home -v 21 --exec java -version
This is useful for one-off commands or testing. For example, to run a legacy application with Java 8:
$ /usr/libexec/java_home -v 1.8 --exec java -jar legacyApp.jar
Check environment variables
Build tools like Maven and Gradle use the JAVA_HOME environment variable to locate Java. Knowing your current JAVA_HOME helps diagnose version conflicts.
Check JAVA_HOME
Run:
$ echo $JAVA_HOME
If JAVA_HOME is set, you'll see a path like:
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home
If the output is blank, JAVA_HOME is not set. This is common and may be fine for basic use, but build tools often require it. Read next: Set JAVA_HOME on Mac.
The path should point to the JDK's Contents/Home directory—not the bin subdirectory.
Check which Java runs by default
The which command shows which java binary executes when you type java:
$ which java
Typical output: /usr/bin/java
To see all java binaries in your PATH (critical for debugging wrong-version issues):
$ which -a java
The first entry in the list is what runs when you type java. See Set JAVA_HOME on Mac to set which Java version will run by default.
Understand why versions might differ
The active Java version depends on:
- JAVA_HOME — If set, this takes priority
- PATH order — The first
javabinary found in PATH runs - System default — What
/usr/libexec/java_homereturns
This means java -version might show a different version than your system default if JAVA_HOME points elsewhere.
Find Java installation locations
Java installations on macOS can be found in standard locations. Knowing where to look helps when troubleshooting or cleaning up old versions.
Primary location:
/Library/Java/JavaVirtualMachines/
List installed JDKs:
$ ls /Library/Java/JavaVirtualMachines/
You'll see directories like:
$ ls /Library/Java/JavaVirtualMachines/
temurin-25.jdk
temurin-21.jdk
jdk1.8.0_392.jdk
Homebrew locations (if installed via Homebrew):
- Apple Silicon:
/opt/homebrew/Cellar/openjdk/ - Intel:
/usr/local/Cellar/openjdk/
User-level installations (from some IDEs):
~/Library/Java/JavaVirtualMachines/
SDKMAN installations:
~/.sdkman/candidates/java/
Directory structure
Each JDK follows this structure:
/Library/Java/JavaVirtualMachines/temurin-25.jdk/
└── Contents/
└── Home/ ← JAVA_HOME points here
├── bin/ ← Contains java, javac, jar, etc.
├── lib/
├── include/
└── conf/
The Contents/Home directory is what JAVA_HOME should reference.
Verify your complete installation
Here's a quick script to check your entire Java setup at once. Copy and paste this into Terminal:
echo "=== Java Runtime Version ===" && java -version 2>&1
echo "\n=== Java Compiler Version ===" && javac -version 2>&1
echo "\n=== JAVA_HOME ===" && echo $JAVA_HOME
echo "\n=== Java Location ===" && which java
echo "\n=== All Installed Versions ===" && /usr/libexec/java_home -V
This runs each check and displays the results. Versions shown should match if your setup is correct.
Check Java for development tools
Different development tools detect Java in different ways. Here's how to verify Java for common tools.
Maven
Maven uses JAVA_HOME to find Java. Check which Java Maven uses:
$ mvn -version
The output shows:
$ mvn -version
Apache Maven 3.9.6
Java version: 25.0.1, vendor: Eclipse Adoptium
Java home: /Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home
If Maven shows a different Java than java -version, check your JAVA_HOME setting.
Gradle
Gradle 6.7+ uses Java toolchains. View detected installations:
$ ./gradlew javaToolchains
Gradle automatically scans standard locations and SDKMAN installations.
IDEs
IntelliJ IDEA auto-detects JDKs but lets you configure specific versions per project (File → Project Structure → Project SDK).
VS Code with Java extensions checks these in order: java.jdt.ls.java.home setting, JDK_HOME, JAVA_HOME, then PATH.
Eclipse uses Preferences → Java → Installed JREs for project JDKs.
If your IDE shows a different Java version than Terminal, it's likely configured to use a specific JDK in its settings. This is normal and often intentional.
Running a test program
If you've installed Java 25, you can compile and run a test program using Java 25's new simplified syntax:
$ echo 'void main() { IO.println("Java 25 works!"); }' > Hello.java
$ java Hello.java
If you see "Java 25 works!" printed, everything is configured correctly. This demonstrates Java 25's compact source files feature. No class declaration or public static void main is required.
You can also test with traditional syntax if you prefer:
$ echo 'public class Test { public static void main(String[] args) { System.out.println("Hello!"); } }' > Test.java
$ javac Test.java
$ java Test
Check for LTS versions
LTS (Long-Term Support) versions receive security updates for years. Production systems and enterprise software typically require LTS versions for stability.
Current LTS versions:
- Java 8 – Released March 2014, supported until December 2030 (Legacy LTS)
- Java 11 – Released September 2018, supported until October 2027 (LTS)
- Java 17 – Released September 2021, supported until October 2027 (LTS)
- Java 21 – Released September 2023, supported until December 2029 (Previous LTS)
- Java 25 – Released September 2025, supported until September 2033 (Current LTS)
Recommendation: For new projects, use Java 25. It's the current LTS with modern features and long-term support. If your project requires an older version, Java 21 is the next best choice.
Read next: Compare Java 21 to Java 25 for a detailed comparison between the two newest LTS versions.
Non-LTS versions (like Java 22, 23, 24) receive updates for only 6 months. Avoid them for production unless you have specific feature requirements.
Identify LTS from output
Many distributions include "LTS" in the version string:
openjdk version "25.0.1" 2025-10-21 LTS
If you don't see "LTS" in the output, check if your major version number is 8, 11, 17, 21, or 25—these are the LTS versions.
Troubleshooting
"java: command not found"
This means Java is not installed or not in your PATH.
Step 1 — Check if any Java exists:
$ /usr/libexec/java_home -V
If you see "Unable to find any JVMs," no Java is installed.
Step 2 — Look for Java manually:
$ ls /Library/Java/JavaVirtualMachines/
If this directory is empty, install Java. If it contains JDK folders, Java is installed but not in your PATH.
For solution details, read next: Unable to Locate a Java Runtime.
"No Java runtime present, requesting install"
This macOS dialog appears when you run a Java command but no JDK is installed.
Important: Do not click "Install" or "More Info." This installs Apple's legacy Java 6, which is severely outdated.
Instead, close the dialog and install a modern JDK. Read next: Install Java on Mac.
Wrong version showing
If java -version shows a different version than expected:
Step 1 — Check JAVA_HOME:
$ echo $JAVA_HOME
If this points to a different version, that's your issue.
Step 2 — Check PATH order:
$ which -a java
The first result is what runs. If multiple Java binaries appear, PATH order determines which one executes.
Step 3 — List all installations:
$ /usr/libexec/java_home -V
Solution:
Set JAVA_HOME to the desired version:
$ export JAVA_HOME=$(/usr/libexec/java_home -v 25)
Add this to ~/.zprofile for persistence. Read next: Set JAVA_HOME on Mac. See the articles Mac Shell Configuration and Set Mac Path for complete instructions.
Version mismatch between java and javac
If java -version and javac -version show different versions, your PATH or JAVA_HOME points to mismatched installations.
Diagnosis:
$ which java
$ which javac
If these return paths to different JDK directories, that's the problem.
Solution:
Ensure both commands use the same JDK:
export JAVA_HOME=$(/usr/libexec/java_home -v 25)
export PATH="$JAVA_HOME/bin:$PATH"
Add to ~/.zprofile and run source ~/.zprofile.
"JAVA_HOME should point to a JDK not a JRE"
This Maven error means JAVA_HOME points to a JRE (or wrong directory).
Verify:
$ ls $JAVA_HOME/bin/javac
If this file doesn't exist, JAVA_HOME points to a JRE, not a JDK.
Solution:
$ export JAVA_HOME=$(/usr/libexec/java_home -v 25)
Modern Java installations are always JDKs, so this usually fixes it.
Class file version mismatch
Error like: "class file has wrong version 69.0, this version only recognizes up to 65.0"
This means code was compiled with a newer Java than your runtime.
Class file version mapping:
- Java 8 – Class file version 52
- Java 11 – Class file version 55
- Java 17 – Class file version 61
- Java 21 – Class file version 65
- Java 25 – Class file version 69
Solution: Either upgrade your runtime Java to match the compile version, or recompile the code targeting an older Java version.
Java Control Panel (legacy)
Before Java 11, Oracle included a Java Control Panel in System Preferences where you could view the installed version.
Current status: Starting with Java 11 (2018), Oracle removed the Java Control Panel. If you have Java 11 or later installed, you will not see a Java icon in System Settings.
All Java configuration now happens through Terminal commands. This is expected behavior, not an error.
If you still see a Java icon in System Settings, you likely have an old Java 8 JRE installed. Consider removing it and installing a modern JDK instead.
What's Next
After checking your Java version, here are common next steps:
- Set JAVA_HOME — For development tools, see Set JAVA_HOME on Mac
- Install Java — If you need to install or upgrade Java, see Install Java on Mac
- Manage multiple versions — If you work on projects requiring different Java versions, see Java Version Managers
My mac.install.guide is a trusted source of installation guides for professional developers. Take a look at the Mac Install Guide home page for tips and trends and see what to install next.