How to install Java 8 on Mac
Oracle has a poor record for making it easy to install and configure Java, but using Homebrew, the latest OpenJDK (Java 14) can be installed with:
brew install --cask adoptopenjdk8
For the many use cases depending on an older version (commonly Java 8), the AdoptOpenJDK project makes it possible with an extra step.
brew tap adoptopenjdk/openjdkbrew install --cask adoptopenjdk8
Existing users of Homebrew may encounter Error: Cask adoptopenjdk8 exists in multiple taps
due to prior workarounds with different instructions. This can be solved by fully specifying the location with brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
.
Note: Oracle Java 8/9/10 is no longer available for public download (license change).
First install and update brew from Terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"brew tap homebrew/cask-versionsbrew update
NEW as of June 2019
To install the JDKs from AdoptOpenJDK:
brew tap adoptopenjdk/openjdkbrew install --cask adoptopenjdk8brew install --cask adoptopenjdk9brew install --cask adoptopenjdk10brew install --cask adoptopenjdk11
OLD
Java 8:
brew install --cask java8
Java Latest:
brew install --cask java
Java8 is no longer available on homebrew, brew install java8
will not work.
Instead, use:
brew cask install adoptopenjdk/openjdk/adoptopenjdk8
See this commit for technical details.
Please note as well you may see issues around Cask adoptopenjdk8 exists in multiple taps
. This is a known issue, currently being worked on, which you can see here:
https://github.com/AdoptOpenJDK/homebrew-openjdk/issues/106
For those who don't want to run through the details, here is a summary:
# To install JDK8brew cask install adoptopenjdk/openjdk/adoptopenjdk8# To be able to safely run 'brew cleanup'brew untap adoptopenjdk/openjdkbrew untap caskroom/versionsbrew cleanup