Homebrew로 Java8 설치하기

2020. 9. 29. 15:48DEV/ETC

반응형

 

Homebrew에서 예전 homebrew/cask에서 homebrew/core로 이전시켜서 명령어가 변경되어 현재 사용 가능한 방법으로 업데이트를 완료했습니다. (2023.03.31)

Homebrew 검색

이 방법은 Java 8 버전 뿐만 아니라 다른 버전도 설치가 가능하니 참고해 주시기 바랍니다.

$ brew search openjdk8 
==> Formulae
openjdk@8                  openjdk                    openjdk@11                 openjdk@17

==> Casks
openttd

Java 8 설치

명령어를 실행해서 설치합니다.

$ brew install openjdk@8

==> Fetching openjdk@8
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/8/manifests/1.8.0.362
Already downloaded: /Users/MiKy/Library/Caches/Homebrew/downloads/2c35c2b809bf1a72b9ff3715943cada2381040624b9461d74ec6de0cad0f94fc--openjdk@8-1.8.0+362.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/8/blobs/sha256:d946fddedabf49b3fa
Already downloaded: /Users/MiKy/Library/Caches/Homebrew/downloads/362b0836e255a93acc1260a8f23dacbecf64191e5f328040e2d0a5c19a971db5--openjdk@8--1.8.0+362.big_sur.bottle.tar.gz
==> Pouring openjdk@8--1.8.0+362.big_sur.bottle.tar.gz
==> Caveats
### symlink 설정
For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /usr/local/opt/openjdk@8/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-8.jdk

openjdk@8 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

### PATH 설정
If you need to have openjdk@8 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openjdk@8/bin:$PATH"' >> /Users/MiKy/.bash_profile

For compilers to find openjdk@8 you may need to set:
  export CPPFLAGS="-I/usr/local/opt/openjdk@8/include"
==> Summary
🍺  /usr/local/Cellar/openjdk@8/1.8.0+362: 782 files, 193.0MB
==> Running `brew cleanup openjdk@8`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

설치 확인

터미널 창을 새로 열어 제대로 설치가 됐는지 확인합니다.

$ java -version

openjdk version "1.8.0_362"
OpenJDK Runtime Environment (build 1.8.0_362-bre_2023_01_22_03_30-b00)
OpenJDK 64-Bit Server VM (build 25.362-b00, mixed mode)

symlink 설정

만약 새창에서 확인을 해도 Java를 인식하지 못한다면 syslink를 연결해줍니다. 해당 명령어는 brew 설치할 때 출력해주니 복사해서 사용합니다.

$ sudo ln -sfn /usr/local/opt/openjdk@8/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-8.jdk

다시 새 터미널 창에서 확인하면 정상적으로 Java가 설치된 것을 확인할 수 있습니다.


Deprecated

최신 버전 Java 설치

Java8이 더이상 최신 버전이 아니므로 다른 방법으로 설치해야 한다.

$ brew cask install java

 

특정 버전 설치하기

$ brew tap adoptopenjdk/openjdk

$ brew cask install adoptopenjdk8
$ brew cask install adoptopenjdk11
$ brew cask install adoptopenjdk13

 

내가 설치하려고 하니 여러 종류가 있다며 선택하라고 한다.

$ brew cask install adoptopenjdk8
Error: Cask adoptopenjdk8 exists in multiple taps:
  homebrew/cask-versions/adoptopenjdk8
  adoptopenjdk/openjdk/adoptopenjdk8

$ brew cask install adoptopenjdk/openjdk/adoptopenjdk8
Updating Homebrew...
==> Downloading https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u265-b01/OpenJDK8U-jdk_x64_mac_hotspot_8u265b01.pkg
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/140418865/6444de00-d246-11ea-8be7-50169d929f88?X-Amz-Algorithm=AWS4-HMAC-S
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'adoptopenjdk8'.
==> Installing Cask adoptopenjdk8
==> Running installer for adoptopenjdk8; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
Password:
installer: Package name is AdoptOpenJDK
installer: Installing at base path /
installer: The install was successful.
package-id: net.adoptopenjdk.8.jdk
version: 1.8.0_265-b01
volume: /
location: Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk
install-time: 1601361732
🍺  adoptopenjdk8 was successfully installed!

$ java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.265-b01, mixed mode)
반응형