Turns out java has been moved into brew core recently, so the correct command as of August 2022 is:
brew install java
Then check your installation by running
java -version
If the result does not looks like this:
openjdk 18.0.2 2022-07-19
OpenJDK Runtime Environment Homebrew (build 18.0.2+0)
OpenJDK 64-Bit Server VM Homebrew (build 18.0.2+0, mixed mode, sharing)
but like this:
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
Then you also need to create a symlink for the system Java wrappers to find this JDK:
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \
/Library/Java/JavaVirtualMachines/openjdk.jdk
Answer from Tim Fulmer on Stack Overflow Top answer 1 of 14
805
Turns out java has been moved into brew core recently, so the correct command as of August 2022 is:
brew install java
Then check your installation by running
java -version
If the result does not looks like this:
openjdk 18.0.2 2022-07-19
OpenJDK Runtime Environment Homebrew (build 18.0.2+0)
OpenJDK 64-Bit Server VM Homebrew (build 18.0.2+0, mixed mode, sharing)
but like this:
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
Then you also need to create a symlink for the system Java wrappers to find this JDK:
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \
/Library/Java/JavaVirtualMachines/openjdk.jdk
2 of 14
137
As an add-on to the accepted answer: to install a certain version of Java, e.g. version 11, run:
brew install openjdk@11
And symlink it:
sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk \
/Library/Java/JavaVirtualMachines/openjdk-11.jdk
Mac Install Guide
mac.install.guide › java › java-25
Install Java 25 on Mac · Mac Install Guide · 2026
How to install Java 25 on Mac step by step. Get the free Java 25 JDK for macOS, install with Homebrew or a PKG, verify the version, and set JAVA_HOME.
Videos
How to Install Java JDK 25 on Mac (M1 / M2 / M3 / MacOS / Macbook) ...
04:08
How to Install Java JDK on Mac Using Homebrew (2025 Easy Guide) ...
How to Install Java 25 on macOS & Setup JAVA_HOME | (M1/M2/M3/M4/M5) ...
02:21
How to Install Java JDK 25 On Mac OS | Install Java on Mac - YouTube
03:22
How to Install Java JDK 25 on Mac OS - YouTube
04:51
How To Download And Install Java 25 On Mac | Java For macOS | JDK ...
Mac Install Guide
mac.install.guide › java › brew-cask
Brew Install Java - Easy Cask Method · 2026
The --cask flag tells Homebrew to install a prebuilt package as a Mac application. The @25 specifies Java 25, the current LTS version. If you enter brew install --cask temurin (without a version number), Homebrew will install the latest version.
Homebrew
formulae.brew.sh › formula › openjdk
Homebrew Formulae: openjdk
brew install openjdk · Also known as: java, openjdk@26 · Development kit for the Java programming language · https://openjdk.org/ License: GPL-2.0-only WITH Classpath-exception-2.0 · Development: Pull requests · Formula JSON API: /api/formula/openjdk.json ·
Medium
medium.com › neural-engineer › installing-the-jdk-on-macos-2025-with-homebrew-temurin-and-openjdk-708f66701cdc
Installing the JDK on macOS (2025) with Homebrew, Temurin, and OpenJDK | by PI | Neural Engineer
December 1, 2025 - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" ... sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \ /Library/Java/JavaVirtualMachines/openjdk.jdk
Mr N
bigsoft.co.uk › blog › 2025 › 11 › 07 › installing-all-the-javas-on-a-mac-and-switching-between-them
Installing all the Javas on a Mac and switching between them
November 7, 2025 - brew install openjdk@8 brew install openjdk@11 brew install openjdk@17 brew install openjdk@21 brew install openjdk@25 ... After the install has completed add this to your ~/.bash_profile and restart the shell. export PATH="$HOME/.jenv/bin:$PATH" eval "$(jenv init -)" If you'd like JAVA_HOME ...
Homebrew
formulae.brew.sh › cask › oracle-jdk
Homebrew Formulae: oracle-jdk
brew install --cask oracle-jdk · Name: Oracle Java Standard Edition Development Kit · JDK from Oracle · https://www.oracle.com/java/technologies/downloads/ Development: Pull requests · Cask JSON API: /api/cask/oracle-jdk.json · Cask code: ...
Mac Install Guide
mac.install.guide › java › java-21
Install Java 21 on Mac · Mac Install Guide · 2026
My guide Brew Install Java - Easy Cask Method covers Java 25 installation instructions with Homebrew. You can follow the guide, substituting 21 for 25.
Mac Install Guide
mac.install.guide › java › brew-formula
Brew Install Java - Formula Method · 2026
Expect the process to take a couple of minutes. Alternatively, you can use the formula alias for the latest version: ... Running brew install java triggers installation of the generic openjdk formula which is currently Java 25.
Homebrew
formulae.brew.sh › cask › oracle-jdk-javadoc@25
oracle-jdk-javadoc@25 — Homebrew Formulae
brew install --cask oracle-jdk-javadoc@25 · Name: Oracle Java Standard Edition Development Kit Documentation · Documentation for the Oracle JDK · https://www.oracle.com/java/technologies/downloads/ Development: Pull requests · Cask JSON ...
Mac Install Guide
mac.install.guide › java
Java on Mac · Mac Install Guide · 2026
Brew Install Java - Formula Method — Install OpenJDK to Homebrew's Cellar with brew install openjdk@25.
Besu-eth
docs.besu-eth.org › how to › install and update java
Install and update Java | Besu documentation
1 month ago - echo $JAVA_HOME · echo $PATH · You should see the JDK versions output. You can install OpenJDK on MacOS using Homebrew. With brew installed, run: brew install openjdk@25 · You can target another version if you prefer. Confirm the installation: java -version ·
Oracle
docs.oracle.com › en › java › javase › 25 › install › installation-jdk-macos.html
4 Installation of the JDK on macOS - Java
September 15, 2025 - For example, JDK 25.0.1 is installed in /Library/Java/JavaVirtualMachines/jdk-25.jdk.
GitHub
github.com › AdoptOpenJDK › homebrew-openjdk
GitHub - AdoptOpenJDK/homebrew-openjdk: AdoptOpenJDK HomeBrew Tap · GitHub
Starred by 1.8K users
Forked by 97 users
Languages Ruby 87.6% | Shell 12.4%