Installing Java 8 & Java 11 on macOS BigSur with Homebrew
2 min readMay 23, 2021
Install Homebrew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
I had an issue with macOS Big Sur (11.2.3)
zsh: command not found: brew
So I added and it was resolved
$ export PATH=/opt/homebrew/bin:$PATH
Add Homebrew TAP
$ brew tap <tabname>
I added tabname
as AdoptOpenJDK/openjdk
$ brew tap AdoptOpenJDK/openjdk
Install AdoptOpenJDK with Homebrew TAP
$ brew install --cask <version>
Install Java 8 with Homebrew Tap
$ brew install --cask adoptopenjdk8
Install Java 11 with Homebrew Tap
$ brew install --cask adoptopenjdk11
Export and add alias
For switching Java version
Add these command in .zshrc file
export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8)
alias java8='export JAVA_HOME=$JAVA_8_HOME'export JAVA_11_HOME=$(/usr/libexec/java_home -v11)
alias java11='export JAVA_HOME=$JAVA_11_HOME'
Run this command after saving
$ source ~/.zshrc
Switch and check Java version
Switch to Java 8, use java8
and check Java version
$ java8
$ java -version
Switch to Java 11, use java11
and check Java version
$ java11
$ java -version