In 2024, even if you can use just brew..

Copybrew install openjdk@17 

Java will be installed here:

Copy/opt/homebrew/opt/openjdk@17/bin/java

for Apple Intel path is /usr/local/... rather than /opt/homebrew/...

For the system Java wrappers to find this JDK, symlink it with:

Copysudo ln -sfn /opt/homebrew/opt/openjdk\@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

resp. for Intel

Copysudo ln -sfn /usr/local/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

Now, running /usr/libexec/java_home -V should show the path to JAVA 17, something like:

Copy17.0.9 (x86_64) "Homebrew" - "OpenJDK 17.0.9" /opt/homebrew/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home

(This is what you are missing btw, if javac or javac --version does not give you a command-not-found but an The operation couldn’t be completed. Unable to locate a Java Runtime.)

In case you see the wrong version, check if the path to JAVA_HOME is set correctly. If not, you could set it by:

Copyexport JAVA_HOME=\$(/usr/libexec/java_home)

...give a try to sdkman, it's far better than brew

Copycurl -s "https://get.sdkman.io" | bash

then open a new shell and try list to see what you could install ;-)

Copysdk list java 

At time of writing you could use:

Copysdk install java 17.0.4.1-tem

Java will be installed here:

Copy/Users/YOUR_USERNAME_HERE/.sdkman/candidates/java/17.0.4.1-tem
Answer from freedev on Stack Overflow
Top answer
1 of 13
407

In 2024, even if you can use just brew..

Copybrew install openjdk@17 

Java will be installed here:

Copy/opt/homebrew/opt/openjdk@17/bin/java

for Apple Intel path is /usr/local/... rather than /opt/homebrew/...

For the system Java wrappers to find this JDK, symlink it with:

Copysudo ln -sfn /opt/homebrew/opt/openjdk\@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

resp. for Intel

Copysudo ln -sfn /usr/local/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

Now, running /usr/libexec/java_home -V should show the path to JAVA 17, something like:

Copy17.0.9 (x86_64) "Homebrew" - "OpenJDK 17.0.9" /opt/homebrew/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home

(This is what you are missing btw, if javac or javac --version does not give you a command-not-found but an The operation couldn’t be completed. Unable to locate a Java Runtime.)

In case you see the wrong version, check if the path to JAVA_HOME is set correctly. If not, you could set it by:

Copyexport JAVA_HOME=\$(/usr/libexec/java_home)

...give a try to sdkman, it's far better than brew

Copycurl -s "https://get.sdkman.io" | bash

then open a new shell and try list to see what you could install ;-)

Copysdk list java 

At time of writing you could use:

Copysdk install java 17.0.4.1-tem

Java will be installed here:

Copy/Users/YOUR_USERNAME_HERE/.sdkman/candidates/java/17.0.4.1-tem
2 of 13
56

Java doesn't mind if you install multiple versions. This is often required; java is not backwards compatible (it tries to change little, but e.g. the java8 to java9 transition broke a ton of stuff, much of it needless and much of it not reasonably expectable or fixable by libraries and apps, so a bunch of java apps and libraries only run on java8 - just an example).

So, yes, you have installed JDK17. Also, yes, if you just run java without specifying which one you want, you so happen to get java13 here.

To see all installed javas, you can run:

Copy/usr/libexec/java_home -V

to 'override', you can use something like (depends on which shell you're using on your mac):

Copyexport JAVA_HOME=`/usr/libexec/java_home -v 17`

(the backticks mean: Run this then take the output of it and treat that as the 'value' of the expression. here, assign it to the JAVA_HOME env var. -v 17 requests a path to java 17. The -V option lists all and is meant for your eyeballs, not for scripts. The -v option is mostly for scripting, and that's how we're using it here).

JAVA_HOME decides which java is used by some things, but the java you get when you just type java is /usr/bin/java, and that executable is actually just a wrapper that picks a java to run from amongst all installed versions. It uses JAVA_HOME to decide which java to actually run. There are wrappers for all the common commands (javac, too). You can always run e.g. which javac to see what that actually runs; you probably see /usr/bin/javac. Everything in /usr/bin is one of these wrapper thingies that looks at JAVA_HOME and then runs the binary it finds there.

Discussions

macos - How to brew install java? - Stack Overflow
Executing brew info openjdk@the-missing-java-versionshould return the location of the installed version and will specify a symlink command that you should run for the system to find the SDK. The response text look something similar to: ...For the system Java wrappers to find this JDK, symlink it with sudo ln -sfn /opt/homebrew/opt/openjdk@17... More on stackoverflow.com
🌐 stackoverflow.com
java - Installing jdk17 on Mac with brew - Stack Overflow
Did you ever get alias java17 working like you want? If so, please update. Thanks. ... Sign up to request clarification or add additional context in comments. ... Worth noting, for those new to Homebrew like me, that the first command downloads available versions. Otherwise Brew only knows about the latest and it says something like Cask 'temurin17' is unavailable. 2024-02-02T13:26:49.99Z+00:00 ... brew install --cask temurin@17 ... More on stackoverflow.com
🌐 stackoverflow.com
Oracle released native Apple Silicon Java JDK 17

Not sure when Open JDK released it, but it's there too https://jdk.java.net/17/

[ edit ] It was released on August 7th this year.https://openjdk.java.net/jeps/391 [/ edit ]

More on reddit.com
🌐 r/MacOS
13
50
September 22, 2021
How do I install java for Mac
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
16
5
May 16, 2025
🌐
Homebrew
formulae.brew.sh › cask › oracle-jdk@17
Homebrew Formulae: oracle-jdk@17
brew install --cask oracle-jdk@17 · 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@17.json · Cask ...
🌐
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: ...
🌐
javaspring
javaspring.net › blog › brew-install-java-17
Mastering `brew install java 17` — javaspring.net
The command brew install openjdk@17 uses Homebrew to fetch and install Java 17 on your system. It takes care of downloading the appropriate JDK package, unpacking it, and setting up the necessary environment variables so that you can start using ...
🌐
TecAdmin
tecadmin.net › install-java-macos
How to Install JAVA on macOS – TecAdmin
April 26, 2025 - Follow the below steps to install the specific version of Java or all the available Java versions on your macOS system. Open a terminal and use brew to search available versions of Java ...
Find elsewhere
🌐
Homebrew
formulae.brew.sh › formula › openjdk@17
Homebrew Formulae: openjdk@17
brew install openjdk@17 · 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@17.json · Formula ...
🌐
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 - 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 ...
🌐
Snyk
snyk.io › blog › install-java-on-macos
How to install Java on macOS | Snyk
April 17, 2024 - brew install openjdk@11 · You can replace '11' with the version number of OpenJDK you want to install. At the time of writing this article, the following OpenJDK Java releases are available on Homebrew: openjdk@8 · openjdk@9 · openjdk@11 · openjdk@17 · You should see a message displaying the version of the installed Java, which should match the version you installed.
🌐
DevQA
devqa.io › brew-install-java
How to Use Brew to Install Java on Mac
To install a specific version of Java using Brew, you can use the adoptopenjdk formula with a version specifier. Here’s how you can do it: ... This will list all the available versions of AdoptOpenJDK that you can install.
🌐
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.
🌐
Java With Us
javawithus.com › home › faq › how to install java 17 on mac
How to Install Java 17 on Mac | Java With Us
April 21, 2026 - Create the symlink so ... make it the default permanently, add the export line to ~/.zshrc. Visit adoptium.net/temurin/releases, filter by Java 17, macOS, and your architecture (aarch64 or x64). Download the .pkg and double-click to install....
🌐
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 and the PATH to be automatically updated when you switch between Java versions then you need to install the jenv plugin that does that.
🌐
GitHub
gist.github.com › gwpantazes › 50810d5635fc2e053ad117b39b597a14
How to install different JDK versions on MacOS with Homebrew · GitHub
i use monterey 12.7 and do NOT have /usr/local/opt too i found my java in the following location: /Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/bin and this path was found in my PATH ... $ brew install openjdk@8 ==> Fetching downloads for: openjdk@8 ✔︎ API Source openjdk@8.rb [Verifying 9.9KB/ 9.9KB] openjdk@8: The x86_64 architecture is required for this software.
🌐
Adam the Automator
adamtheautomator.com › install-java-on-mac
How to Install Java on Mac
November 30, 2022 - To install the latest version of Java on your Mac: 1. Run the below brew update command to update Homebrew.
🌐
Java With Us
javawithus.com › home › faq › how to install java 17 on windows, mac and linux
How to Install Java 17 on Windows, Mac and Linux | Java With Us
April 21, 2026 - Install Java 17 LTS on any OS: winget or Temurin MSI on Windows, brew install openjdk@17 on Mac, apt install openjdk-17-jdk on Ubuntu.
🌐
Medium
medium.com › miro-engineering › how-to-switch-between-java-lts-versions-8-11-and-17-on-mac-cb6717d1272
How to switch between Java LTS versions 8, 11, and 17 on Mac | by Lothar Schulz | Miro Engineering | Medium
November 25, 2021 - # version 17 brew install openjdk@17 sudo ln -sfn /usr/local/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk# version 11 brew install openjdk@11 sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk ...
🌐
javaspring
javaspring.net › blog › installing-java-17-on-mac
Installing Java 17 on Mac: A Comprehensive Guide — javaspring.net
# Update Homebrew brew update # ...17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk · Visit the Oracle Java SE Downloads page....