How to Install Java on MacOS
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Latest
$ brew cask install adoptopenjdk
# Other Versions
$ brew tap AdoptOpenJDK/openjdk
$ brew cask install adoptopenjdk11
- jEnv를 사용할 것이므로 homebrew의 path 설정 안내는 무시
$ brew install jenv
# Shell
$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(jenv init -)"' >> ~/.bash_profile
# Shell: zsh
$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
$ echo 'eval "$(jenv init -)"' >> ~/.zshrc
$ jenv add Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
$ jenv global openjdk64-11.0.6
$ jenv versions
system
11.0
11.0.6
* openjdk64-11.0.6 (set by /Users/user/.jenv/version)
$ jenv enable-plugin export
$ exec $SHELL -l
$ echo ${JAVA_HOME}
/Users/user/.jenv/versions/openjdk64-11.0.6
$ java --version
openjdk 11.0.6 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)
Step 4. Install Maven/Gradle
# Maven
$ brew install maven
$ mvn --version
# Gradle
$ brew install Gradle
$ gradle --version
- maven과 gradle의 dependency로 openjdk가 설치되지만 adoptopenjdk를 사용할 것이므로 무시