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
🌐
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.
🌐
Homebrew
formulae.brew.sh › cask › oracle-jdk@25
Homebrew Formulae: oracle-jdk@25
brew install --cask oracle-jdk@25 · 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@25.json · Cask ...
🌐
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 ·
🌐
freeCodeCamp
freecodecamp.org › news › how-to-install-java-on-mac
How to Install Java on Mac in 2026
February 20, 2026 - This is a good choice if you don't use Homebrew. See Install Java on Mac for detailed instructions. Homebrew formula. The command brew install openjdk@25 installs a Homebrew-managed build.
🌐
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 ...
Find elsewhere
🌐
Homebrew
formulae.brew.sh › cask › graalvm-jdk@25
graalvm-jdk@25 — Homebrew Formulae
brew install --cask graalvm-jdk@25 · Name: GraalVM Java Development Kit · GraalVM from Oracle · https://www.graalvm.org/ Development: Pull requests · Cask JSON API: /api/cask/graalvm-jdk@25.json · Cask code: graalvm-jdk@25.rb on GitHub ...
🌐
DevQA
devqa.io › brew-install-java
How to Use Brew to Install Java on Mac
If not, you can install it via: $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" If you already have brew installed, make sure you have the latest version by running the following command in a terminal
🌐
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.
🌐
Medium
medium.com › ayuth › set-up-multiple-java-dev-environments-for-macos-2025-edition-5aa4335f3d70
Set up Multiple Java Dev Environments for macOS — 2025+ Edition
November 3, 2025 - In this case, I will use Microsoft ... how to manage them using jenv. We’ll install using these commands: $ brew install microsoft-openjdk $ brew install microsoft-openjdk@21...
🌐
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 › 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 ·
🌐
GitHub
gist.github.com › gwpantazes › 50810d5635fc2e053ad117b39b597a14
How to install different JDK versions on MacOS with Homebrew · GitHub
Note that it's poured from the OpenJDK formula. $ brew install openjdk@11 # Install OpenJDK 11 · Homebrew does not offer an obvious way to install an older feature release of Java other than the current generally-available feature release.
🌐
Microsoft Learn
learn.microsoft.com › en-us › java › openjdk › install
Install the Microsoft Build of OpenJDK | Microsoft Learn
brew install --cask microsoft-openjdk@11 # OR brew install --cask microsoft-openjdk@17 # OR brew install --cask microsoft-openjdk@21 # OR brew install --cask microsoft-openjdk@25 · To uninstall the Microsoft Build of OpenJDK installed through ...
🌐
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.