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
🌐
GitHub
gist.github.com › gwpantazes › 50810d5635fc2e053ad117b39b597a14
How to install different JDK versions on MacOS with Homebrew · GitHub
Java.net | | 16.ea.24 | open | | 16.ea.24-open | | 16.ea.7.lm | open | | 16.ea.7.lm-open | | 16.ea.2.pma | open | | 16.ea.2.pma-open | | 15.0.1 | open | | 15.0.1-open | | 14.0.2 | open | | 14.0.2-open | | 14.0.1 | open | local only | 14.0.1-open | | 13.0.2 | open | | 13.0.2-open | | 12.0.2 | open | | 12.0.2-open | >>> | 11.0.2 | open | installed | 11.0.2-open | | 10.0.2 | open | | 10.0.2-open | | 9.0.4 | open | | 9.0.4-open ... Brew has an openjdk@8 formula.
Discussions

Upgrade openjdk's formula to install version 24
Output of brew config HOMEBREW_VERSION: 4.4.31 ORIGIN: https://github.com/Homebrew/brew HEAD: 0046519c08cd3967e0934c82195361ac7e76c567 Last commit: 3 days ago Branch: stable Core tap JSON: 17 Apr 1... More on github.com
🌐 github.com
1
2
Installing JDK on a new mac

I'd recommend homebrew for package management in general and sdkman for java (and related ecosystem) development tools.

More on reddit.com
🌐 r/java
17
21
December 8, 2017
Go 1.20.1 and Go 1.19.6 versions are released
View the release notes for more information: https://go.dev/doc/devel/release#go1.20.1 You can download binary and source distributions from the Go website: https://go.dev/dl/ More on reddit.com
🌐 r/golang
8
92
February 15, 2023
Install Homebrew on Ubuntu 22.04 Linux ARM
This is a Homebrew problem, not an Ubuntu problem. You want to ask on r/homebrew . More on reddit.com
🌐 r/Ubuntu
7
1
May 11, 2022
🌐
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
🌐
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: ...
🌐
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 ·
🌐
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
🌐
Mac Install Guide
mac.install.guide › java › brew-cask
Brew Install Java - Easy Cask Method · 2026
Brew install Java on Mac. One command to install the recommended Temurin JDK. The cask method without PATH or symlink configuration. How to fix common Homebrew Java issues.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-install-java-on-mac
How to Install Java on Mac in 2026
February 20, 2026 - See Install Java on Mac for detailed instructions. Homebrew formula. The command brew install openjdk@25 installs a Homebrew-managed build. This approach requires manual symlink configuration before macOS can discover it.
🌐
Medium
ymkfelix.medium.com › how-to-set-up-multiple-java-versions-on-a-macbook-8bae41345f72
How to set up multiple Java versions on a MacBook? | by Ye Min Ko | Medium
August 13, 2024 - For example, if you want to use java 17 and 21, install them with the following command. brew install openjdk@17 brew install openjdk@21 · Just run the commands after installing both versions of Java to create symlinks.
🌐
Medium
medium.com › @manvendrapsingh › installing-many-jdk-versions-on-macos-dfc177bc8c2b
Installing & switching between multiple JDK on macOS | by Manvendra P Singh | Medium
February 20, 2023 - After this completes, we can use homebrew to install available formulae or cask with just one line commands brew install xxxx or brew install --cask xxxx · First, let's search Homebrew to find available java versions.
🌐
Medium
medium.com › @haroldfinch01 › step-by-step-guide-installing-and-switching-java-versions-on-mac-osx-f3896b9872f4
Step-by-Step Guide: Installing and Switching Java Versions on Mac OSX | by Harold Finch | Medium
May 21, 2024 - Install Java 8 · brew install openjdk@8 · Install Java 11 · brew install openjdk@11 · Install Java 17 · brew install openjdk@17 · After installing each version, follow the instructions provided by Homebrew to add the Java versions to your PATH. jenv is a Java environment manager that makes it easy to switch between different versions of Java.
🌐
GitHub
github.com › jbranchaud › til › blob › master › java › install-java-on-mac-with-brew.md
til/java/install-java-on-mac-with-brew.md at master · jbranchaud/til
This is because OpenJDK the open-source ... and the exact command with correct paths can be found from running the following: $ brew info openjdk ......
Author   jbranchaud
🌐
Mac Install Guide
mac.install.guide › java › brew-formula
Brew Install Java - Formula Method · 2026
BBrew install Java with the OpenJDK Homebrew formula. How to install the Java JDK with brew, add the required symlink, and configure Java correctly on macOS.
🌐
GeeksforGeeks
geeksforgeeks.org › installation guide › how-to-install-openjdk-in-macos
How to Install OpenJDK in macOS - GeeksforGeeks
May 6, 2026 - brew install openjdk · Homebrew will download and install the latest version of OpenJDK. Step 4: Verify the Installation · To confirm that OpenJDK has been installed successfully, check the version: java -version · You should see output showing ...
🌐
Homebrew
formulae.brew.sh › cask › oracle-jdk@21
Homebrew Formulae: oracle-jdk@21
brew install --cask oracle-jdk@21 · 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@21.json · Cask ...
🌐
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 ...
🌐
GitHub
github.com › orgs › Homebrew › discussions › 2405
mac version 11.6 , M1, brew install openjdk@11 · Homebrew · Discussion #2405
brew install openjdk@11 openjdk@11 11.0.12 is already installed java -version error: The operation couldn’t be completed. Unable to locate a Java Runtime. Please visit http://www.java.com for infor...
🌐
DEV Community
dev.to › gabethere › installing-java-on-a-mac-using-homebrew-and-jevn-12m8
Brew Install Java: Installing Java on MacOS using Homebrew and JEnv - DEV Community
August 28, 2020 - First, we need to install JEnv using homebrew, run the following command: ... $ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile $ echo 'eval "$(jenv init -)"' >> ~/.bash_profile ...