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/openjdk
brew 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.
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/openjdk
brew 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:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew tap homebrew/cask-versions
brew update
NEW as of June 2019
To install the JDKs from AdoptOpenJDK:
brew tap adoptopenjdk/openjdk
brew install --cask adoptopenjdk8
brew install --cask adoptopenjdk9
brew install --cask adoptopenjdk10
brew install --cask adoptopenjdk11
OLD
Java 8:
brew install --cask java8
Java Latest:
brew install --cask java
Unable to install Java 8 on MBP M4
How to install Java 8 on osx macOS Mojave with Homebrew? - Stack Overflow
Installing JDK on a new mac
I'd recommend homebrew for package management in general and sdkman for java (and related ecosystem) development tools.
More on reddit.comWhat is the easiest way to install Java 11 on Macos?
Videos
Hello,
I need Java for some applications and I just downloaded the latest Java installer (jre-8u431-macosx-aarch64) from Oracle aaand … it's not installing. It tries to install and says something like java could not be installed and "OS error code 1".
I searched for hours on Google and couldn't find anything. Did anyone have a solution to this? I'm running Sequoia 15.2.
The older Oracle JDKs are gone from Homebrew now. Use OpenJDK instead:
brew tap adoptopenjdk/openjdk
brew cask install adoptopenjdk8
OpenJDK is a drop-in replacement for the Oracle JDK in most places, so this should work fine for you with no code or build process changes.
This answer is outdated.
You can install Java 8 on macOS Mojave like this:
brew tap caskroom/versions
brew cask install java8
In case the latest java version was already installed, uninstall it with:
brew cask remove java