So, noone wastes more time on this, to install temurin17, execute:

Copybrew tap homebrew/cask-versions
brew install --cask temurin17
Answer from Goaul on Stack Overflow
🌐
Homebrew
formulae.brew.sh › cask › corretto@11
Homebrew Formulae: corretto@11
brew install --cask corretto@11 · Name: AWS Corretto JDK · OpenJDK distribution from Amazon · https://corretto.aws/ Development: Pull requests · Cask JSON API: /api/cask/corretto@11.json · Cask code: corretto@11.rb on GitHub · Current ...
🌐
Homebrew
formulae.brew.sh › cask › corretto
Homebrew Formulae: corretto
brew install --cask corretto · Name: AWS Corretto JDK · OpenJDK distribution from Amazon · https://corretto.aws/ Development: Pull requests · Cask JSON API: /api/cask/corretto.json · Cask code: corretto.rb on GitHub · Current version: ...
Discussions

Provide Homebrew formulas for Corretto
One of the easiest ways to install Java on macOS is via Homebrew's brew cask install java which tracks the latest version (currently 11) or brew cask install java8 which tracks the newest version of Java8 that's available. Can we get a version of these formulas that track Corretto instead? More on github.com
🌐 github.com
9
January 16, 2019
java - Installing jdk17 on Mac with brew - Stack Overflow
I am trying to install jdk17 with brew, while also having java8, java11 and java16 installed. In order to install 8, 11 and 16 I ran: brew tap adoptopenjdk/openjdk brew install --cask adoptopenjdk8 More on stackoverflow.com
🌐 stackoverflow.com
Corretto{8||11} for Apple M1?
This is related to corretto/corretto-8#42 (and equivalent issue for corretto11) with an extra ask: % brew install corretto11 Updating Homebrew... ==> Auto-updated Homebrew! Updated 2 taps (homeb... More on github.com
🌐 github.com
3
February 12, 2021
Add the ability to upgrade Corretto JDK 11 through command line
Is your feature request related to a problem? Please add the ability to update the JDK through command line. It is painful to download, install the package and update the path for every new release Describe a solution you would like Prov... More on github.com
🌐 github.com
1
July 19, 2019
🌐
GitHub
github.com › corretto › corretto-11 › issues › 18
brew installation for MacOS? · Issue #18 · corretto/corretto-11
March 25, 2019 - For MacOS users, the preferred way to install Corretto (and keep it up-to-date) would be through the brew package installer. All other JDKs can be installed with brew. Please consider developing a brew cask for Corretto. You can take a l...
Author   corretto
🌐
AWS
docs.aws.amazon.com › corretto › corretto 11 user guide › amazon corretto 11 guide for macos › amazon corretto 11 installation instructions for macos 11 or later
Amazon Corretto 11 Installation Instructions for macOS 11 or later - Amazon Corretto 11
Double-click the downloaded file to begin the installation wizard and follow the steps in the wizard. Once the wizard completes, Amazon Corretto 11 is installed in /Library/Java/JavaVirtualMachines/.
🌐
Homebrew
formulae.brew.sh › cask › corretto@21
Homebrew Formulae: corretto@21
brew install --cask corretto@21 · Name: AWS Corretto JDK · OpenJDK distribution from Amazon · https://corretto.aws/ Development: Pull requests · Cask JSON API: /api/cask/corretto@21.json · Cask code: corretto@21.rb on GitHub · Current ...
🌐
GitHub
github.com › corretto › corretto-8 › issues › 42
Provide Homebrew formulas for Corretto · Issue #42 · corretto/corretto-8
January 16, 2019 - One of the easiest ways to install Java on macOS is via Homebrew's brew cask install java which tracks the latest version (currently 11) or brew cask install java8 which tracks the newest version of Java8 that's available. Can we get a version of these formulas that track Corretto instead?
Author   corretto
Find elsewhere
🌐
GitHub
github.com › corretto › corretto-11 › issues › 175
Corretto{8||11} for Apple M1? · Issue #175 · corretto/corretto-11
February 12, 2021 - % brew install corretto11 Updating Homebrew... ==> Auto-updated Homebrew! Updated 2 taps (homebrew/cask-versions and homebrew/cask). ==> New Casks lightform ==> Updated Casks Updated 3 casks.
Author   corretto
🌐
GitHub
github.com › corretto › corretto-11 › issues › 43
Add the ability to upgrade Corretto JDK 11 through command line · Issue #43 · corretto/corretto-11
July 19, 2019 - Provide an alternate way to install and upgrade Corretto JDK either through HomeBrew, AWS SDK or NPM
Author   corretto
🌐
Reddit
reddit.com › r/matlab › r2024a: java without amazon corretto
r/matlab on Reddit: R2024a: java without Amazon Corretto
August 20, 2024 -

Hi all, 

I just downloaded 2024a for my MacBook Pro with the Apple M3 Pro chip. To run MATLAB, you need a java runtime environment set up on your machine, and MathWorks recommends Amazon Corretto. For various reasons, I wasn't too keen on getting an Amazon-owned background software on my system. Since it was a bit difficult to get MATLAB to see my local java environment, I thought I’d share my workaround to install java11 and have MATLAB recognize it. 

In terminal: 

$ brew install java11
$ export CPPFLAGS="-I/opt/homebrew/opt/openjdk@11/include"
$ sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

*Notes: 

  • This is assuming one has homebrew setup on their machine

  • The 2nd and 3rd lines were obtained from the suggestions provided within the terminal after install (e.g. <<For the system Java wrappers to find this JDK, symlink it with sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk>>

And 

<<For compilers to find openjdk@11 you may need to set:
export CPPFLAGS="-I/opt/homebrew/opt/openjdk@11/include">>

If y’all have any reason why this is not as good of an idea as having Corretto, I’m very happy to hear it! 

Thanks and all the best

🌐
DevQA
devqa.io › brew-install-java
How to Use Brew to Install Java on Mac
Replace 11 with the desired version number. 5 - Brew will then download and install the specified version of Java.
🌐
Manuals+
manuals.plus › home › amazon › amazon corretto 11 user guide: installation and usage
Amazon Corretto 11 User Guide: Installation and Usage
November 5, 2025 - A comprehensive user guide for Amazon Corretto 11, detailing installation procedures for various operating systems like Linux, Windows, and macOS, along with Docker integration an…
🌐
Homebrew
formulae.brew.sh › cask › corretto@25
Homebrew Formulae: corretto@25
brew install --cask corretto@25 · Name: AWS Corretto JDK · OpenJDK distribution from Amazon · https://corretto.aws/ Development: Pull requests · Cask JSON API: /api/cask/corretto@25.json · Cask code: corretto@25.rb on GitHub · Current ...
🌐
Reddit
reddit.com › r/learnprogramming › [deleted by user]
[deleted by user] : r/learnprogramming
October 28, 2022 - 4.3M subscribers in the learnprogramming community. A subreddit for all questions related to programming in any language.
🌐
Stack Overflow
stackoverflow.com › questions › 75224482 › macos-tells-me-java-version-is-11-but-i-just-installed-version-19-with-homebrew
macOS tells me Java version is 11 but I just installed version 19 with Homebrew - Stack Overflow
I would think that Java (version 19.0.1) is already installed, but if I check it as suggested at How to brew install java? : ... openjdk 11.0.18 2023-01-17 LTS OpenJDK Runtime Environment Corretto-11.0.18.10.1 (build 11.0.18+10-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.18.10.1 (build 11.0.18+10-LTS, mixed mode)
Top answer
1 of 11
1214

Note: These solutions work for various versions of Java including Java 8 through Java 21 (the LTS version). This includes alternative JDK's from OpenJDK, Oracle, IBM, Azul, Amazon Correto, Graal and more.

You have a few options for how to do the installation as well as manage JDK switching. Installation can be done by Homebrew, SDKMAN, asdf, or a manual install. Switching can be done by SDKMAN, asdf, or manually by setting JAVA_HOME. All of these are described below.


TL;DR - Preferred Methods of Installation

You can install Java using whatever method you prefer including SDKMAN, asdf, Homebrew, or a manual install of the tar.gz file. The advantage of a manual install is that the location of the JDK can be placed in a standardized location for Mac OSX.

However, there are easier options such as SDKMAN and asdf that also will install other important and common tools for the JVM. These two primary options are described here.

Installing and Switching versions with SDKMAN

SDKMAN is a bit different and handles both the install and the switching. SDKMAN also places the installed JDK's into its own directory tree, which is typically ~/.sdkman/candidates/java. SDKMAN allows setting a global default version, and a version specific to the current shell.

  1. Install SDKMAN from https://sdkman.io/install

  2. List the Java versions available to make sure you know the version ID

    sdk list java
    
  3. Install one of those versions, for example, Java 21 LTS:

    sdk install java 21-open 
    

    Or java 19:

    sdk install java 19.0.2-open
    
  4. Make Java 17 the default version:

    sdk default java 17-open
    

    Or switch to 17 for the current terminal session:

    sdk use java 17-open
    

When you list available versions for installation using the list command, you will see a wide variety of distributions of Java:

sdk list java

And install additional versions, such as JDK 11 from Amazon:

sdk install java 11.0.14.10.1-amzn

SDKMAN can work with previously installed existing versions. Just do a local install giving your own version label and the location of the JDK:

sdk install java my-local-13 /Library/Java/JavaVirtualMachines/jdk-13.jdk/Contents/Home

And use it freely:

sdk use java my-local-13

SDKMAN will automatically manage your PATH and JAVA_HOME for you as you change versions. And as a note, it installs Java versions to ~/.sdkman/candidates/java/.

More information is available in the SDKMAN Usage Guide along with other SDK's it can install and manage such as Gradle, Maven, Kotlin, Quarkus, Spring Boot, and many others.


Installing and Switching versions with "asdf"

asdf is a version manager that supports installing and managing most languages, frameworks, and developer/devops tools. It has language specific plugins including one for Java.

  1. First, install asdf via https://asdf-vm.com/guide/getting-started.html (read there to setup your shell correctly), or more simply:

    brew reinstall asdf
    

    and read the doc for setting up your shell correctly, but if you are using asdf from Homebrew with ZSH you can execute this command to finish setup:

    echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc
    
  2. Then install the Java plugin via https://github.com/halcyon/asdf-java

    asdf plugin add java
    

    and read the doc for setting up your shell correctly before continuing. Basically it says to add the following to your ~/.zshrc file (assuming you are not using another shell):

    . ~/.asdf/plugins/java/set-java-home.zsh
    
  3. Now list Java versions:

    asdf list-all java
    
  4. Install your favorite flavor and version:

    asdf install java openjdk-21
    

    or install the latest:

    asdf install java latest
    

Other important commands are...

  • List your installed versions:

    asdf list java
    
  • Set a global Java version:

    asdf global java openjdk-21
    
  • Set a local Java version for a directory:

    asdf local java openjdk-19
    

It's that easy! asdf will automatically manage your PATH and JAVA_HOME for you as you change versions. As a note, asdf installs Java versions to ~/.asdf/installs/java.

There are other languages and plugins for asdf here from the repository page: https://github.com/asdf-vm/asdf-plugins


Other Methods of Installation

Install with Homebrew

The version of Java available in Homebrew Cask previous to October 3, 2018 was indeed the Oracle JVM. Now, however, it has now been updated to OpenJDK. Be sure to update Homebrew and then you will see the lastest version available for install.

  1. install Homebrew if you haven't already. Make sure it is updated:

     brew update
    
  2. Add the casks tap:

     brew tap homebrew/cask-versions
    

    These casks change their Java versions often, and there might be other taps out there with additional Java versions.

  3. Look for installable versions:

     brew search java  
    

    or for Eclipse Temurin versions:

     brew search temurin     
    
  4. Check the details on the version that will be installed:

     brew info java
    

    or for the Temurin version:

     brew info temurin
    
  5. Install a specific version of the JDK such as java11, temurin8, temurin11, temurin17, or just java or temurin for the most current of that distribution. For example:

     brew install java
    
     brew install --cask temurin
    

And these will be installed into /Library/Java/JavaVirtualMachines/ which is the traditional location expected on Mac OSX. There might be additional steps to make the JDK active reported at the end of the install process.

Install manually from OpenJDK download page:

If you need any and every version of Java, this is a good place to look.

  1. Download OpenJDK for Mac OSX from http://jdk.java.net/ (for example Java 17 and Java 21)

  2. Unarchive the OpenJDK tar, and place the resulting folder (i.e. jdk-19.jdk) into your /Library/Java/JavaVirtualMachines/ folder since this is the standard and expected location of JDK installs. You can also install anywhere you want in reality.

  3. Set JAVA_HOME environment variable to point at direction where you unarchived the JDK.

For further information see the answer specific to manual installation. Also see the section below "Switching versions manually" for more information on how to manage multiple manual installations.

Other installation options:

Some other flavours of OpenJDK are:

Azul Systems Java Zulu certified builds of OpenJDK can be installed by following the instructions on their site.

Zulu® is a certified build of OpenJDK that is fully compliant with the Java SE standard. Zulu is 100% open source and freely downloadable. Now Java developers, system administrators, and end-users can enjoy the full benefits of open source Java with deployment flexibility and control over upgrade timing.

Amazon Correto OpenJDK builds have an easy to use an installation package for Java 8, 11, 17, and Java 21. It installs to the standard /Library/Java/JavaVirtualMachines/ directory on Mac OSX.

Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Corretto comes with long-term support that will include performance enhancements and security fixes. Amazon runs Corretto internally on thousands of production services and Corretto is certified as compatible with the Java SE standard. With Corretto, you can develop and run Java applications on popular operating systems, including Linux, Windows, and macOS.

Microsoft Java JDK - certified builds of OpenJDK from Microsoft.


Where is my JDK?!?!

To find locations of previously installed Java JDK's installed at the default system locations, use:

/usr/libexec/java_home -V

Matching Java Virtual Machines (4):
19 (x86_64) "Homebrew" - "OpenJDK 19" /usr/local/Cellar/openjdk/19/libexec/openjdk.jdk/Contents/Home
18.0.1.1 (x86_64) "Homebrew" - "OpenJDK 18.0.1.1" /usr/local/Cellar/openjdk/18.0.1.1/libexec/openjdk.jdk/Contents/Home
17 (x86_64) "Homebrew" - "OpenJDK 17" /usr/local/Cellar/openjdk/17/libexec/openjdk.jdk/Contents/Home
11, x86_64: "Java SE 11" /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
1.8.301.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home /usr/local/Cellar/openjdk/17/libexec/openjdk.jdk/Contents/Home

You can also report just the location of a specific Java version using -v. For example for Java 17:

/usr/libexec/java_home -v 17

/usr/local/Cellar/openjdk/17/libexec/openjdk.jdk/Contents/Home

Knowing the location of the installed JDK's is also useful when using tools like JEnv, or adding a local install manually to SDKMAN -- and you need to know where to find them.

If you need to find JDK's installed by other tools, check these locations:

  • SDKMAN installs to ~/.sdkman/candidates/java/
  • asdf install to ~/.asdf/installs/java

Version Switching

If you are using SDKMAN or asdf you are already covered and can stop reading! Otherwise, here are some options to switch existing VM installations.

Switching versions manually

The Java executable is a wrapper that will use whatever JDK is configured in JAVA_HOME, so you can change that to also change which JDK is in use.

For example, if you installed or untar'd JDK 16 to /Library/Java/JavaVirtualMachines/jdk-16.jdk if it is the highest version number it should already be the default, if not you could simply set:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home

And now whatever Java executable is in the path will see this and use the correct JDK.

A simple way to change JDKs is to create a function in your ~/.bashrc or ~/.zshrc file:

jdk() {
    version=$1
    export JAVA_HOME=$(/usr/libexec/java_home -v"$version");
    java -version
}

And then change JDKs simply by:

jdk 1.8
jdk 9
jdk 11
jdk 13

Edits:

  • removed Jabba and JENV as both appear to have stagnated, issue count is climbing dramatically, and issues/PR's are not being addressed by the maintainers.
2 of 11
41

This is how I did it.

Step 1: Install Java 11

You can download Java 11 dmg for mac from here: https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html

Step 2: After installation of Java 11. Confirm installation of all versions. Type the following command in your terminal.

Copy/usr/libexec/java_home -V

Step 3: Edit .bash_profile

Copysudo nano ~/.bash_profile

Step 4: Add 11.0.1 as default. (Add below line to bash_profile file).

Copyexport JAVA_HOME=$(/usr/libexec/java_home -v 11.0.1)

to switch to any version

Copyexport JAVA_HOME=$(/usr/libexec/java_home -v X.X.X)

Now Press CTRL+X to exit the bash. Press 'Y' to save changes.

Step 5: Reload bash_profile

Copysource ~/.bash_profile

Step 6: Confirm current version of Java

Copyjava -version