관리 메뉴

웹개발자의 기지개

[Java] mac 에서 여러개의 버전 설치하기 ( adoptopenjdk, temurin ) 본문

Java

[Java] mac 에서 여러개의 버전 설치하기 ( adoptopenjdk, temurin )

http://portfolio.wonpaper.net 2024. 4. 10. 21:28

mac 상에서 여러개의 java 버전을 설치해보자.

 

구글링만 해도 다양하게 볼 수 있지만 나름대로 정리해 보았다.

참고로 필자는 mac m2 환경이다.

 

homebrew 로 설치한다.

 

adoptopenjdk 저장소를 추가한다.

brew tap adoptopenjdk/openjdk

 

다운로드 가능한 java 버전 검색

brew search adoptopenjdk

 

 

자 이제는 버전별로 각각 설치하면 된다.

 

brew install adoptopenjdk11

brew install adoptopenjdk13

 

그러면 설치되어 있는 버전들을 모두 확인해보기

/usr/libexec/java_home -V

 

이제는 설치된 자바 경로에 따라 내가 원하는 자바버전을 설정해보자.

nano ~/.zshrc

 

121 라인에 셋팅할 버전을 설정한다.

 

그리고, 마지막으로 이 내용을 전용으로 적용해둔다.

source ~/.zshrc

 

---------------

 

자 시간이 흘렀다.  필자로 이래저래 자바 작업을 spring boot 를 선호하여 작업하는데,  

언젠가 부터 이제는 java 17 이상은 되어야 프로젝트를 그나마 시작할 수 있다.

그래도 현재 아직까지 과거의 java 8, 11 도 되어 있는 기존 프로젝트도 많이 있다.

 

일단 이제부터는 17이상을 준비해야하는데,

 

mac 상으로도 17이상을 연이어 homebrew 형태로 설치하고자 하였다.

문제는 adoptopenjdk 형태로 17이상을 설치시도했는데,  deprecated 되었다는 안타까운 소식 ㄷㄷㄷ.

adoptopenjdk 17 이하는 설치가능하다.

 

 

https://github.com/AdoptOpenJDK/homebrew-openjdk?tab=readme-ov-file#-deprecation-notice-

 

GitHub - AdoptOpenJDK/homebrew-openjdk: AdoptOpenJDK HomeBrew Tap

AdoptOpenJDK HomeBrew Tap. Contribute to AdoptOpenJDK/homebrew-openjdk development by creating an account on GitHub.

github.com

 

temurin 을 이용하면 최신 17, 21 등등을 설치할 수 있다.

https://adoptium.net/temurin/releases/

 

Latest Releases | Adoptium

 

adoptium.net

 

2024-04-10 현재 새로운 java17 을 설치하려니 아래와 같은 오류가 났다.

 

Cask 'adoptopenjdk-jre' definition is invalid: 'appcast' stanza failed with: Calling the `appcast` stanza is disabled! Use the `livecheck` stanza instead.

 

jongwon@ijong-won-ui-MacBookPro libexec % brew search adoptopenjdk

Error: Cask 'adoptopenjdk-jre' definition is invalid: 'appcast' stanza failed with: Calling the `appcast` stanza is disabled! Use the `livecheck` stanza instead.

Please report this issue to the adoptopenjdk/openjdk tap (not Homebrew/brew or Homebrew/homebrew-core), or even better, submit a PR to fix it:

  /opt/homebrew/Library/Taps/adoptopenjdk/homebrew-openjdk/Casks/adoptopenjdk-jre.rb:9

 

 

brew tap homebrew/cask-versions

 

jongwon@ijong-won-ui-MacBookPro libexec % brew tap homebrew/cask-versions

==> Tapping homebrew/cask-versions

Cloning into '/opt/homebrew/Library/Taps/homebrew/homebrew-cask-versions'...

remote: Enumerating objects: 278431, done.

remote: Counting objects: 100% (278431/278431), done.

remote: Compressing objects: 100% (84059/84059), done.

remote: Total 278431 (delta 193894), reused 278291 (delta 193860), pack-reused 0

Receiving objects: 100% (278431/278431), 70.19 MiB | 4.65 MiB/s, done.

Resolving deltas: 100% (193894/193894), done.

Tapped 261 casks (296 files, 78MB).

 

 

long term 버전인 17과 21 모두 설치하였다.

 

# 특정버전 설치

brew install --cask temurin17

brew install --cask temurin21

 

jongwon@ijong-won-ui-MacBookPro libexec % brew install --cask temurin17 

==> Downloading https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.10%2B7/OpenJ

==> Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e65be/3729

############################################################################################### 100.0%

==> Installing Cask temurin17

==> Running installer for temurin17 with sudo; the password may be necessary.

Password:

installer: Package name is Eclipse Temurin

installer: Installing at base path /

installer: The install was successful.

🍺  temurin17 was successfully installed!

 

jongwon@ijong-won-ui-MacBookPro libexec % brew install --cask temurin21

==> Downloading https://formulae.brew.sh/api/cask.jws.json

############################################################################################# 100.0%

==> Downloading https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/Ope

==> Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e65be/60

############################################################################################# 100.0%

==> Installing Cask temurin21

==> Running installer for temurin21 with sudo; the password may be necessary.

Password:

installer: Package name is Eclipse Temurin

installer: Installing at base path /

installer: The install was successful.

🍺  temurin21 was successfully installed!

 

설치된 java 버전확인

/usr/libexec/java_home -V  

 

jongwon@ijong-won-ui-MacBookPro libexec % /usr/libexec/java_home -V    

Matching Java Virtual Machines (6):

    21.0.2 (arm64) "Eclipse Adoptium" - "OpenJDK 21.0.2" /Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home

    17.0.10 (arm64) "Eclipse Adoptium" - "OpenJDK 17.0.10" /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home

    11.0.20 (arm64) "Oracle Corporation" - "Java SE 11.0.20" /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home

    11.0.16.1 (arm64) "Microsoft Build of OpenJDK" - "Microsoft Build of OpenJDK 11" /Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home

    1.8.0_302 (x86_64) "Eclipse Temurin" - "Eclipse Temurin 8" /Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home

    1.8.0_292 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home

 

설치한 java 버전을 추가한다.

nano ~/.zshrc

----------------------------------------------------------

export PATH=/opt/homebrew/bin:$PATH

 

export JAVA_HOME_8=$(/usr/libexec/java_home -v8)

export JAVA_HOME_11=$(/usr/libexec/java_home -v11)

export JAVA_HOME_17=$(/usr/libexec/java_home -v17)

export JAVA_HOME_21=$(/usr/libexec/java_home -v21)

 

# current version

export JAVA_HOME=$JAVA_HOME_17

----------------------------------------------------------

 

내용 적용하기

source ~/.zshrc

 

jongwon@ijong-won-ui-MacBookPro libexec % source ~/.zshrc

jongwon@ijong-won-ui-MacBookPro libexec % java -version

openjdk version "17.0.10" 2024-01-16

OpenJDK Runtime Environment Temurin-17.0.10+7 (build 17.0.10+7)

OpenJDK 64-Bit Server VM Temurin-17.0.10+7 (build 17.0.10+7, mixed mode)

 

 

 

참고 : https://praetoriani.tistory.com/40

참고 : https://wook-lab.tistory.com/21

참고 : https://adoptium.net/temurin/releases/

 

 

 

 

Comments