Java development kit
OpenJDK (Open Java Development Kit) is an implementation of the Java Platform, Standard Edition (Java SE). It is the result of an effort Sun Microsystems began in 2006, four years before the … Wikipedia
Factsheet
Original author Sun Microsystems
Developers Oracle, OpenJDK and Java Community, Red Hat, Azul Systems, IBM, Microsoft, Amazon, Apple, SAP
Release May 8, 2007; 19 years ago (2007-05-08)
Factsheet
Original author Sun Microsystems
Developers Oracle, OpenJDK and Java Community, Red Hat, Azul Systems, IBM, Microsoft, Amazon, Apple, SAP
Release May 8, 2007; 19 years ago (2007-05-08)
🌐
Medium
medium.com › @kirebyte › using-homebrew-to-install-java-jdk11-on-macos-2021-4a90aa276f1c
Using HomeBrew to Install Java JDK11 on MacOS (2021) | by Erick Gustavo López Siordia | Medium
August 5, 2021 - $ brew install java11 · If you skip this step the system won’t be able to find a java runtime for you to use. sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk · If you see something ...
🌐
Homebrew
formulae.brew.sh › formula › openjdk@11
Homebrew Formulae: openjdk@11
brew install openjdk@11 · Also known as: java11 · Development kit for the Java programming language · https://openjdk.org/ License: GPL-2.0-only · Development: Pull requests · Formula JSON API: /api/formula/openjdk@11.json · Formula code: ...
Discussions

Installing Java via Homebrew
You logged in using a passkey from another device. For faster access next time, add a passkey to this device · I am documenting how to install Java11 on macOS via homebrew, so that this topic will pop up via search if you run into problems (like I did) More on groups.io
🌐 groups.io
October 31, 2023
What is the easiest way to install Java 11 on Macos?
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://imgur.com/a/fgoFFis ) 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
9
3
June 15, 2022
macos - How can I upgrade my mac to OpenJDK 11 using Homebrew? - Ask Different
If I would have an older version of Java JDK on my mac such as Java SE 8 or OpenJDK 8, what would be a quick way to upgrade to OpenJDK 11 using Homebrew (using the brew command)? Motivation for using Homebrew: Homebrew provides an easy way to do reproducible installation of a number of system ... More on apple.stackexchange.com
🌐 apple.stackexchange.com
January 23, 2019
macos - How do I install Java on Mac OSX allowing version switching? - Stack Overflow
For manual install I think you need to set JAVA_HOME in order to select a specific version, something like export JAVA_HOME=$(/usr/libexec/java_home -v ) in your .bash_profile 2018-09-27T08:20:12.383Z+00:00 ... Java in brew cask changed to OpenJDK 11 yesterday, Oct 3, 2018. More on stackoverflow.com
🌐 stackoverflow.com
🌐
DevQA
devqa.io › brew-install-java
How to Use Brew to Install Java on Mac
In this article we show how to install Java on Mac using Homebrew, and how to allow to switch between different versions such as Java8, Java11, Java13 and latest Java version. Before we start, make sure you have Homebrew installed on your 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
🌐
GitHub
gist.github.com › productinfo › ac0af7e776cd40aa7dbf62e08af807e3
How to install different Java Versions with Homebrew on MacOS · GitHub
$ brew info java11 # Confirm information about the formula. Note that it's poured from the OpenJDK formula. $ brew install java11 # Install OpenJDK 11
🌐
UnoGeeks
unogeeks.com › home › blog › brew install java 11
Brew Install Java 11
December 25, 2023 - Once Homebrew is installed, you can use it to install Java 11. Java 11 is available as a Cask, so you can install it using the brew cask command:
🌐
GitHub
github.com › orgs › Homebrew › discussions › 2405
mac version 11.6 , M1, brew install openjdk@11 · Homebrew · Discussion #2405
echo $JAVA_HOME /opt/homebrew/Cellar/openjdk@11/11.0.16/libexec/openjdk.jdk/Contents/Home java --version openjdk 11.0.16 2022-07-19 OpenJDK Runtime Environment Homebrew (build 11.0.16+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.16+0, mixed mode)
Find elsewhere
🌐
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.
🌐
Smart People I Know
smartpeopleiknow.com › 2023 › 10 › 23 › how-to-work-with-java-on-your-mac-including-having-multiple-versions-of-java-on-your-mac
How to work with Java on your Mac, including having multiple versions of Java on your Mac – Smart People I Know
October 23, 2023 - If you want to install an older ... this: $ brew install java11 · If you’ve done this a few times, you may have a few different version of Java installed liked me, and if you enter the following command it may look something like this: % ...
🌐
Groups.io
groups.io › g › jmriusers › topic › installing_java_via_homebrew › 99910198
jmriusers@groups.io | Installing Java via Homebrew
October 31, 2023 - You logged in using a passkey from another device. For faster access next time, add a passkey to this device · I am documenting how to install Java11 on macOS via homebrew, so that this topic will pop up via search if you run into problems (like I did)
🌐
mixable Blog
mixable.blog › home › brew: install java on macos
brew: install Java on macOS | mixable Blog
May 23, 2024 - This will install Java version 11.0.10 as listed in the output of brew info java11 above.
🌐
Javaspring
javaspring.net › blog › brew-install-java-11
Mastering `brew install java 11`: A Comprehensive Guide | JavaSpring.net
June 7, 2025 - Open the Terminal: Launch the Terminal application on your macOS. Update Homebrew: Before installing any package, it’s a good practice to update Homebrew to ensure you have the latest package information. Run the following command: ... brew install openjdk@11 This command will download and ...
🌐
Medium
medium.com › w-logs › installing-java-11-on-macos-with-homebrew-7f73c1e9fadf
Installing Java 11 on MacOS with HomeBrew | by Wai Loon | w:Logs | Medium
January 27, 2019 - $ brew cask install java · Add the following aliases to .bash_profile. export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8) export JAVA_11_HOME=$(/usr/libexec/java_home -v11) alias java8='export JAVA_HOME=$JAVA_8_HOME' alias java11='export ...
🌐
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@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 ...
🌐
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 ...
🌐
Mkyong
mkyong.com › home › java › how to install java jdk on macos
How to install Java JDK on macOS - Mkyong.com
January 19, 2021 - 2.1 Install and upgrade Homebrew. 2.2 The brew search java has no java8? Terminal · % brew search java ==> Formulae app-engine-java java javacc jslint4java pdftk-java google-java-format java11 javarepl libreadline-java · 2.3 The Java 8 is available at the openjdk@8 formula. The openjdk is the same as the java formula, and it always contains the latest JDK GA version; the openjdk@11 is the same as the java11 formula, containing JDK 11.
🌐
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 ...
Top answer
1 of 2
12

Recommended commands to install OpenJDK 11 from AdoptOpenJDK (with notes after the # sign):

brew tap adoptopenjdk/openjdk # assuming this tap was not already added
brew cask install adoptopenjdk11 # this command *may* need a password to succeed

Note that OpenJDK as used by AdoptOpenJDK is open source under GPL v2 license with a Classpath exception.

This answer assumes that a recent version of Homebrew is installed, with brew cask install enabled and working.

At this point, assuming that no newer version of Java or Java JDK is installed, java -version shows me openjdk version "11.0.3" and javac --version shows me javac 11.0.3 (with no JAVA_HOME environment variable in use). The following commands show both JDK versions installed:

  • /usr/libexec/java_home -V
  • ls /Library/Java/JavaVirtualMachines

To install latest version of OpenJDK from AdoptOpenJDK:

brew tap adoptopenjdk/openjdk # (if not already added)
brew cask install adoptopenjdk # (*may* need a password to succeed)

Alternative installation of OpenJDK from download.oracle.com - with no AdoptOpenJDK tap needed:

To install OpenJDK 11 from download.oracle.com:

brew cask install java11 # (*may* need a password to succeed)

To install most recent OpenJDK version from download.oracle.com:

brew cask install java # (*may* need a password to succeed)

Here is the source of the java cask: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/java.rb

To find related packages on Homebrew:

  • brew search jdk (shows both AdoptOpenJDK and the Oracle JDK)
  • brew search java (see notes below)

According to this article, newer versions of Java JDK from Oracle are under GPL v2 license with a Classpath exception (they seemed to link to the same page on the non-https site).

Note that some previous java packages such as java8 are still using Oracle JDK instead of OpenJDK. How to install and verify an older OpenJDK version using AdoptOpenJDK is described in: How can I install java openjdk 8 on High Sierra

2 of 2
1

If for any reason you want an installation not depending on a package manager (frequently happening if you need to use several versions as a developer) you can download the appropriate zip file from https://www.azul.com/downloads/zulu/zulu-mac/. Unzip it and add the bin directory to your $PATH if needed.

As of 2019-02-21 Java 7, 8 and 11 are available as latest releases.

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