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
Java
Java software reduces costs, drives innovation, and improves application services. Learn more about Java, the #1 development platform.
Technologies
Java can help reduce costs, drive innovation, & improve application services; the #1 programming language for IoT, enterprise architecture, and cloud computing.
Java Downloads
Learn more about automating these downloads · Gain expert support, rigorously tested Oracle JDK updates including all supported versions and long-term support for production, fleet automation with Java Management Service, BPRs for urgent customer reported issues, and more with an Oracle Java SE subscription. ... Also available for development, personal use, and to run other licensed Oracle products. GraalVM for JDK 17 ...
JavaSE
Oracle strongly recommends that all Java SE 17 users upgrade to this release. ... Java SE 11.0.31 is the latest release of Java SE 11 Platform. Oracle strongly recommends that all Java SE 11 users upgrade to this release. ... Java SE 8u491 is the latest release of Java SE 8 Platform. Oracle strongly recommends that all Java SE 8 users upgrade to this release. JDK for ARM releases are available on the same page as the downloads ...
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.

🌐
CodeJava
codejava.net › java-core › install-openjdk-17-on-macos
Download and Install OpenJDK 17 on macOS
Visit the official download page of OpenJDK 17 at https://jdk.java.net/17, and click on the download link for macOS/x64 if your computer running on Intel’s CPU, or choose macOS/AArch64 for Apple’s CPU:It’s strongly recommend to verify SHA256 checksum of the downloaded file against the ...
🌐
Oracle
oracle.com › java › technologies › downloads
Download the Latest Java LTS Free
Download the Java including the latest version 17 LTS on the Java SE Platform. These downloads can be used for any purpose, at no cost, under the Java SE binary code license.
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › install › installation-jdk-macos.html
5 Installation of the JDK on macOS - Java
April 21, 2026 - JDK is installed in /Library/Java/JavaVirtualMachines/jdk-<FEATURE>.jdk where <FEATURE> is the feature release number. For example, JDK 17.0.1 is installed in /Library/Java/JavaVirtualMachines/jdk-17.jdk. ... When starting a Java application through the command line, the system uses the default JDK.
🌐
CodeJava
codejava.net › java-se › install-oracle-jdk-17-on-macos
Download and Install Oracle JDK 17 on macOS
April 28, 2022 - Head over to the official download page of Oracle JDK 17. You will see the following page:Click the link next to Arm 64 DMG Installer if your Mac running on Apple’s CPU, else click the link next to x64 DMG Installer for Intel’s CPU.And you should verify SHA256 checksum of the downloaded ...
🌐
Homebrew
formulae.brew.sh › cask › oracle-jdk@17
Homebrew Formulae: oracle-jdk@17
https://www.oracle.com/java/technologies/downloads/ Development: Pull requests · Cask JSON API: /api/cask/oracle-jdk@17.json · Cask code: oracle-jdk@17.rb on GitHub · Current version: 17.0.12 · Requirements: macOS ·
Find elsewhere
🌐
Bell Software
bell-sw.com › pages › downloads
Download JDK 8, 11, 17, 21, 25, 26 | Java Builds for Linux, Windows and macOS
JDK 17 LTS · JDK 21 LTS · JDK 25 LTS · JDK 26 · Java Version · Any · Any · Release Version · Any · Any · Operating system · Any · Any · Architecture · Any · Any · Bitness · Any · Any · Package Type · Any · Any · Release notes · Installation guide · Supported Configurations · Terms of use · Source code · Windows · Liberica 25.0.3+11, Windows 64 bit, Standard · Download · Mac ·
🌐
Oracle
oracle.com › java › technologies › javase › jdk17-0-13-later-archive-downloads.html
Java SE 17 Archive Downloads (JDK 17.0.13 and later)
WARNING: Older versions of the JDK are provided to help developers debug issues in older systems. They are not updated with the latest security patches and are not recommended for use in production. For production use Oracle recommends downloading the latest JDK version.
🌐
OpenLogic
openlogic.com › openjdk-downloads
OpenJDK Downloads | OpenLogic
In August 2019, OpenLogic recognized that the current state of Java WebStart technology in OpenJDK was not as capable as the Oracle JDK equivalent. The build was missing critical functionality such as site exceptions, jar key matching, Windows Proxy settings, and other functions. OpenLogic added functionality to IcedTea-Web to bring parity with Oracle’s WebStart distribution. These upgrades were accepted into IcedTea-Web 2.0. OpenLogic now provides free, quarterly builds of OpenJDK 8, OpenJDK 11, OpenJDK 17, and OpenJDK 21 for Linux, Windows, and MacOS.
🌐
Medium
medium.com › java-mvp › install-openjdk-17-on-macos-c0ddb3ac9f0e
Install OpenJDK 17 on MacOS. Oracle JDK 17 ist currently the latest… | by datatec.studio | Java MVP | Medium
January 17, 2023 - Long story short, assume you don’t know which java you already have on your laptop, following steps might be help you to install OpenJDK 17 on your macOS. java -version # Ignore the output if it said "no matches found:" sudo rm -fr /Users/$(whoami)/Library/Java/JavaVirtualMachines/* # Ignore the output if it said "no matches found:" sudo rm -fr /Library/Java/JavaVirtualMachines/* /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew uninstall openjdk@11 brew install openjdk@17 sudo ln -sfn /usr/local/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk java -version
🌐
Stony Brook University
www3.cs.stonybrook.edu › ~amione › CSE114_Course › materials › resources › InstallingJava17.pdf pdf
Installing Java 17 Downloading
Scroll down to Java SE Development Kit 17.0.2 downloads. Click on the appropriate platform ... For mac, use the x76 DMG installer. Click the link to download the file. For windows, use the x86 MSI Installer. Click the link to download the file. ... This will open the dmg and show a pkg file.
🌐
javaspring
javaspring.net › blog › java-17-download-mac
Java 17 Download and Installation on Mac: A Comprehensive Guide — javaspring.net
On the Adoptium homepage, select the Java version as 17. Choose the appropriate package for your Mac (usually the .dmg file for macOS). Click the download button. If you have Homebrew installed on your Mac, you can use the following command ...
🌐
Azul Systems
azul.com › home › azul downloads
Java 8, 11, 17, 21, 25 Download for Linux, Windows and macOS
January 30, 2023 - Click here to download the Azul Zulu Builds of OpenJDK for Java 8, 11, 17, 21, 25 for Linux, Windows and macOS. Also download Azul Platform Prime.
🌐
Medium
michaeldacanay.medium.com › how-to-install-java-on-mac-1952ba52e796
How to Install Java on Mac - Michael Dacanay - Medium
July 20, 2023 - Here’s the Java 17 LTS download, and I use the ARM64 DMG installer for my M1 chip MacBook. Press enter or click to view image in full size · https://www.oracle.com/java/technologies/downloads/#jdk17-mac · Press enter or click to view image ...
🌐
Tutorials24x7
tutorials24x7.com › java › how-to-install-java-17-on-mac
How To Install Java 17 On Mac | Tutorials24x7
September 26, 2021 - This tutorial provides all the steps required to install Oracle JDK 17 on Mac systems. It provides the steps required to install Java 17 on macOS Catalina.