OS X에서 jenv를 이용한 JDK 버전관리
Java 버전 확인
$ java -version
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+11, mixed mode)
설치되어 있는 Java 목록 확인
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
11.0.9, x86_64: "AdoptOpenJDK 11" /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
10.0.2, x86_64: "AdoptOpenJDK 10" /Library/Java/JavaVirtualMachines/adoptopenjdk-10.jdk/Contents/Home
1.8.0_272, x86_64: "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
1.7.0_80, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
homebrew를 이용한 OpenJDK 설치
최신 버전 설치
$ brew cask install adoptopenjdk
버전별 설치
$ brew cask install adoptopenjdk13
jenv 를 이용한 버전 관리
jenv 설치
$ brew install jenv
jenv에 version를 추가
$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-13.jdk/Contents/Home
jenv에 추가된 versions 확인
$ jenv versions
1.7
1.7.0.80
1.8
1.8.0.272
11
11.0
11.0.9
12
12.0
12.0.2
13
13.0
13.0.2
openjdk64-1.8.0.272
openjdk64-11.0.9
openjdk64-12.0.2
openjdk64-13.0.2
oracle64-1.7.0.80
jenv에 plugin 추가
$ jenv enable-plugin maven
$ jenv enable-plugin export
jenv를 이용하여 JDK 버전 변경
$ jenv global 1.8.0.272
$ jenv local 1.8.0.272
# 변경 전 확인
$ java -version
openjdk version "13.0.2" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 13.0.2+8)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13.0.2+8, mixed mode, sharing)
# 변경 시도
$ jenv global 1.8.0.272
# 변경 후 확인
$ java -version
openjdk version "1.8.0_272"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_272-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.272-b10, mixed mode)