참고문서)
https://brew.sh/index_ko
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install jenv
$ brew tap AdoptOpenJDK/openjdk
# Shell: bash
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(jenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile
# Shell: zsh
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(jenv init -)"' >> ~/.zshrc
$ source ~/.zshrc
jdk version 별 설치 하기)
$ brew install --cask adoptopenjdk8
$ brew install --cask adoptopenjdk11
$ brew install --cask adoptopenjdk15
$ brew install --cask adoptopenjdk16
jenv 추가)
$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home
$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-16.jdk/Contents/Home
jenv 사용)
Usage: jenv <command> [<args>]
Some useful jenv commands are:
commands List all available jenv commands
local Set or show the local application-specific Java version
global Set or show the global Java version
shell Set or show the shell-specific Java version
rehash Rehash jenv shims (run this after installing executables)
version Show the current Java version and its origin
versions List all Java versions available to jenv
which Display the full path to an executable
whence List all Java versions that contain the given executable
add Add JDK into jenv. A alias name will be generated by parsing "java -version"
See `jenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/jenv/jenv/blob/master/README.md
$ jenv versions
system
1.8
* 1.8.0.242 (set by /Users/mzc02-henryjeong/.jenv/version)
11.0
11.0.6
13.0
13.0.2
15
15.0
15.0.2
16
openjdk64-1.8.0.242
openjdk64-11.0.6
openjdk64-13.0.2
openjdk64-15.0.2
openjdk64-16
JAVA_HOME 변경을 위한 plugin 설치)
$ jenv enable-plugin export
(주의 : eval "$(jenv init -)" 설정이 빠져 있으면 동작 하지 않습니다.)
jenv global 설정)
/Users/henryjeong/.jenv/version
$ jenv global 11.0
$ jenv global
11.0
jenv local 설정)
$ jenv local 16
$ jenv local
16
$ java -version
openjdk version "16" 2021-03-16
OpenJDK Runtime Environment AdoptOpenJDK (build 16+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 16+36, mixed mode, sharing)
로컬 설정은 해당 버전이 필요한 Application 에 들어가서 실행 하시면 됩니다.