DEV BLOG

[개발환경] jenv

|

jenv

jEnv is a command line tool to help you forget how to set the JAVA_HOME environment variable

자꾸 jdk 새로운 버전 설치할 때마다 까먹어서 기억용으로 정리해두었다!

jenv 설치된 자바 버전 확인

$ jenv versions

brew로 새로운 jdk 설치

  1. openjdk 버전 검색
 $ brew tap adoptopenjdk/openjdk
 $ brew search jdk
=> Formulae
openjdk                                                                        openjdk@11
==> Casks
adoptopenjdk                           adoptopenjdk11-openj9-jre-large        adoptopenjdk13-openj9-jre              adoptopenjdk8-openj9
adoptopenjdk-jre                       adoptopenjdk11-openj9-large            adoptopenjdk13-openj9-jre-large        adoptopenjdk8-openj9-jre
adoptopenjdk-openj9                    adoptopenjdk12                         adoptopenjdk13-openj9-large            adoptopenjdk8-openj9-jre-large
adoptopenjdk-openj9-jre                adoptopenjdk12-jre                     adoptopenjdk14                         adoptopenjdk8-openj9-large
adoptopenjdk-openj9-jre-large          adoptopenjdk12-openj9                  adoptopenjdk14-jre                     adoptopenjdk9
adoptopenjdk-openj9-large              adoptopenjdk12-openj9-jre              adoptopenjdk14-openj9                  jdk-mission-control
adoptopenjdk10                         adoptopenjdk12-openj9-jre-large        adoptopenjdk14-openj9-jre              oracle-jdk
adoptopenjdk11                         adoptopenjdk12-openj9-large            adoptopenjdk14-openj9-jre-large        oracle-jdk-javadoc
adoptopenjdk11-jre                     adoptopenjdk13                         adoptopenjdk14-openj9-large            sapmachine-jdk
adoptopenjdk11-openj9                  adoptopenjdk13-jre                     adoptopenjdk8 ✔
adoptopenjdk11-openj9-jre              adoptopenjdk13-openj9                  adoptopenjdk8-jre
  1. 원하는 버전 설치
$ brew install --cask adoptopenjdk14
installer: Package name is AdoptOpenJDK
installer: Upgrading at base path /
installer: The upgrade was successful.
package-id: net.adoptopenjdk.14.jdk
version: 14.0.2+12
volume: /
location: Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk
install-time: 1598527106
🍺  adoptopenjdk14 was successfully installed!

jenv에 설치한 jdk 등록

설치시 알려준 location 참고하여 등록

$ jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home/
openjdk64-14.0.2 added
14.0.2 added
14.0 added

Use

Configure global version

$ jenv global oracle64-1.6.0.39

Configure local version (per directory)

$ jenv local oracle64-1.6.0.39

Configure shell instance version

$ jenv shell oracle64-1.6.0.39

(+) install for MAC M1

brew install --cask homebrew/cask-versions/adoptopenjdk8
brew install --cask homebrew/cask-versions/microsoft-openjdk11
brew install --cask homebrew/cask-versions/microsoft-openjdk17