Closed3

homebrewでopenjdkを道入

nerusannerusan
shell
$ brew info openjdk@11
==> openjdk@11: stable 11.0.22 (bottled) [keg-only]
Development kit for the Java programming language
https://openjdk.java.net/
/usr/local/Cellar/openjdk@11/11.0.22 (674 files, 298.6MB)
  Poured from bottle using the formulae.brew.sh API on 2024-02-08 at 15:57:16
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/o/openjdk@11.rb
License: GPL-2.0-only
==> Dependencies
Build: autoconf ✘, pkg-config ✔
Required: giflib ✔, harfbuzz ✔, jpeg-turbo ✔, libpng ✘, little-cms2 ✔
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

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

If you need to have openjdk@11 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc

For compilers to find openjdk@11 you may need to set:
  export CPPFLAGS="-I/usr/local/opt/openjdk@11/include"
==> Analytics
install: 34,037 (30 days), 85,865 (90 days), 340,250 (365 days)
install-on-request: 24,794 (30 days), 64,978 (90 days), 246,420 (365 days)
build-error: 369 (30 days)

$ brew install openjdk@11
# シンボリックリンクを指定
$ sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
# パスを指定
$ echo 'export PATH="/usr/local/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc
# コンパイルする際は必要(Javaでコンパイルする必要がない場合は不要)
$ export CPPFLAGS="-I/usr/local/opt/openjdk@11/include"
nerusannerusan

バージョンを変えたい時

.zshrcに記載するパスを変更する

このスクラップは2024/02/13にクローズされました