How can I install java openjdk 8 on High Sierra or newer macOS [duplicate]

Fastest Solution

Use the adoptopenjdk cask

See also https://discourse.brew.sh/t/how-to-install-openjdk-with-brew/712/4

To install latest:

brew install --cask adoptopenjdk

To install a specific version

brew tap AdoptOpenJDK/openjdk
brew install --cask adoptopenjdk8
brew install --cask adoptopenjdk9

Manual Solution

If you are looking to just bring down the binary without actually installing it, simply navigate to https://adoptopenjdk.net


I found this is the easiest way to download and install. Navigate here and choose platform.


You can also install openjdk from Zulu, a commercial vendor that builds and releases OpenJDK free of charge here

You can just manually install it from the above link!


Upon running

brew cask install adoptopenjdk8

If you get this error

Error: Unknown command: cask

With the newer versions of brew, cask won't work like this anymore.

Use:

brew tap AdoptOpenJDK/openjdk
brew install adoptopenjdk8 --cask