-
Notifications
You must be signed in to change notification settings - Fork 0
Java ‐ Install JDKs
Our Java services currently run on either Java 8 or Java 11.
Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew tap homebrew/cask-versions
brew install openjdk@8
sudo ln -sfn /usr/local/opt/openjdk@8/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-8.jdk
brew install openjdk@11
sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
/usr/libexec/java_home -V
Since different services run on different JRE’s, switching between JDK versions is necessary when running the build commands from the command line.
-
Add the following to ~/.zshrc (or ~/.bashrc if using bash)
jdk() { version=unset JAVA_HOME; export JAVA_HOME=$(/usr/libexec/java_home -v"$version"); java -version }
-
Source to reflect changes
source ~/.zshrc
% jdk 1.8
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-bre_2021_10_20_23_15-b00)
OpenJDK 64-Bit Server VM (build 25.312-b00, mixed mode)
% jdk 11
openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment Homebrew (build 11.0.12+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode)
java -version