{{announcement.body}}
{{announcement.title}}

Installing OpenJDK Versions on Macs

DZone 's Guide to

Installing OpenJDK Versions on Macs

Take a look at how you can quickly get started with OpenJDK with this tutorial that gives you commands for installing version 7-11 through a Mac Terminal.

· Open Source Zone ·
Free Resource

In this article, I will be using Homebrew to install OpenJDK versions on the Mac.

We use brew install to install JDK versions 8,9,10, and brew cask install for version 11 and above.             

All the brew commands are executed in the Terminal window on the Mac.

Install OpenJDK Versions 8, 9, and 10

brew tap AdoptOpenJDK/openjdk 

==> Tapping adoptopenjdk/openjdk

Cloning into '/usr/local/Homebrew/Library/Taps/adoptopenjdk/homebrew-openjdk'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 8 (delta 2), reused 2 (delta 0), pack-reused 0
Unpacking objects: 100% (8/8), done.
Tapped 3 formulae (36 files, 29.4KB).


brew search /adoptopenjdk/ 

==> Formulae

adoptopenjdk/openjdk/adoptopenjdk-openjdk10    
adoptopenjdk/openjdk/adoptopenjdk-openjdk9
adoptopenjdk/openjdk/adoptopenjdk-openjdk8

==> Casks
adoptopenjdk

The Formulae section contains the identifiers for the various JDK versions.

To install a specific JDK version: brew install <identifier

e.g. to install OpenJDK 8:  brew install adoptopenjdk/openjdk/adoptopenjdk-openjdk8 

==> Installing adoptopenjdk-openjdk8 from adoptopenjdk/openjdk
==> Downloading https://github.com/AdoptOpenJDK/openjdk8-releases/releases/download/jdk8u172-
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/85294734
######################################################################## 100.0%

Warning: This brew TAP is being DEPRECATED soon in favour of using brew cask. 
Please check out https://github.com/AdoptOpenJDK/homebrew-openjdk/blob/master/README.md for more info
/usr/local/Cellar/adoptopenjdk-openjdk8/jdk8u172-b11: 577 files, 170.4MB, built in 40 seconds

JAVA_HOME should be set by the developer to /usr/local/Cellar/adoptopenjdk-openjdk8/jdk8u172-b11. 

Install OpenJDK Version 11

brew cask install adoptopenjdk

[~] > brew cask install adoptopenjdk
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
No changes to formulae.

==> Satisfying dependencies
==> Downloading https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11%2B28/Open
Already downloaded: /Users/pbelathur/Library/Caches/Homebrew/downloads/154143ed1f7540b66ebceb732063de00c27467a5796256bea5e4492690833116--OpenJDK11-jdk_x64_mac_hotspot_11_28.tar.gz
==> Verifying SHA-256 checksum for Cask 'adoptopenjdk'.
==> Installing Cask adoptopenjdk
Password:
adoptopenjdk was successfully installed!

JAVA_HOME should be set by the developer to /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk. 

Topics:
java ,openjdk ,homebrew ,mac ,code snippet ,installation ,open source

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}