Manage multiple jdk versions on macOS
Using homebrew It's super easy to install any JDK version from the adoptopenjdk builds:
Andreas-Mac-mini:installer a.leofreddi$ brew tap AdoptOpenJDK/openjdk
==> Tapping adoptopenjdk/openjdk
Cloning into '/Users/a.leofreddi/Applications/homebrew/Library/Taps/adoptopenjdk/homebrew-openjdk'...
remote: Enumerating objects: 24, done.
remote: Counting objects: 100% (24/24), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 24 (delta 12), reused 10 (delta 4), pack-reused 0
Unpacking objects: 100% (24/24), done.
Tapped 14 casks (67 files, 84.9KB).
Andreas-Mac-mini:installer a.leofreddi$ brew search adoptopenjdk
==> Casks
adoptopenjdk ✔ adoptopenjdk11 adoptopenjdk11-openj9 adoptopenjdk12 adoptopenjdk12-openj9 adoptopenjdk8 ✔ adoptopenjdk8-openj9 adoptopenjdk9 ✔
adoptopenjdk10 adoptopenjdk11-jre adoptopenjdk11-openj9-jre adoptopenjdk12-jre adoptopenjdk12-openj9-jre adoptopenjdk8-jre adoptopenjdk8-openj9-jre
Andreas-Mac-mini:installer a.leofreddi$ brew cask install adoptopenjdk9
Then one can easily switch version using java_home
:
export JAVA_HOME=`/usr/libexec/java_home -v 9`