To install the lastest version, type the following command into a Terminal:

brew install --cask temurin

To install older versions, use the following commands (version 1.8 in this example):

brew tap homebrew/cask-versions
brew install --cask temurin8



jEnv helps to switch between different Java versions.

To install jEnv, use the following command:

brew install jenv

After installation, open/create the hidden “.zshrc” file in your home folder and add the following lines to the end of the file:

export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"

Now you need to logout and login to your local account to be able to use jEnv.

Add Java version

To add one or more installed Java versions to jEnv, use the following command in a Terminal:

jenv add /Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/

The actual folder you need to add may vary.

Change Java version

To change between installed Java versions using jEnv, use the following commands in a Terminal:

#this will show the added java versions
jenv versions
   * 11.0.13 (set by /Users/glibly/.jenv/version)

#you may use any of those names to change the java version
jenv global

#now you may check the Java version
java -version
   openjdk version "1.8.0_312"
   OpenJDK Runtime Environment (Temurin)(build 1.8.0_312-b07)
   OpenJDK 64-Bit Server VM (Temurin)(build 25.312-b07, mixed mode)