2024-02-20に更新

環境構築

何が どれ
PC iMac
チップ Apple M1
OS Sonoma
IDE IntelliJ IDEA (Community Edition)
パッケージ管理システム 当然!「Homebrew」だッ!
javaバージョン管理 jenv
使用言語 kotlin 1.9.22
フレームワーク spring boot
ターミナル iTerm2

Homebrewはインストールされているところから開始

各種パッケージ導入

特にバージョン違いの管理をする予定はないが手癖でいれる

$ brew install jenv

IDE

$ brew install intellij-idea-ce

JDK Apple M1に対応してるJDKを探しつつ、なぜかjava17も入れておく jenvの挙動試すの久々だったし

$ brew install java
$ brew install openjdk@17

M1向けjdkはzulu使えみたいなんあるけどbrewのページだとおkになってんだよな よくわからん

jenvいれる
公式ドキュメントを参考に

$ brew install jenv

メモ忘れたけど公式ドキュメント参考にdoctorとかして最終的にzshrcにはこれを追加

export PATH="/Users/sakamotokeika/.jenv/shims:${PATH}"
export JENV_SHELL=zsh
export JENV_LOADED=1
unset JAVA_HOME
unset JDK_HOME
source '/opt/homebrew/Cellar/jenv/0.5.6/libexec/libexec/../completions/jenv.zsh'
jenv rehash 2>/dev/null
jenv refresh-plugins
jenv() {
  type typeset &> /dev/null && typeset command
  command="$1"
  if [ "$#" -gt 0 ]; then
    shift
  fi

  case "$command" in
  enable-plugin|rehash|shell|shell-options)
    eval `jenv "sh-$command" "$@"`;;
  *)
    command jenv "$command" "$@";;
  esac
}

jenvにjdk追加

$ brew info openjdk@17
==> openjdk@17: stable 17.0.9 (bottled) [keg-only]
Development kit for the Java programming language
[https://openjdk.java.net/](https://openjdk.java.net/)
/opt/homebrew/Cellar/openjdk@17/17.0.9 (635 files, 304.9MB)
  Poured from bottle using the formulae.brew.sh API on 2024-02-13 at 18:57:08
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/o/[email protected]
License: GPL-2.0-only with Classpath-exception-2.0
==> Dependencies
Build: autoconf ✔, pkg-config ✔
Required: giflib ✔, harfbuzz ✔, jpeg-turbo ✔, libpng ✔, little-cms2 ✔
==> Requirements
Build: Xcode (on macOS) ✘
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk

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

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

For compilers to find openjdk@17 you may need to set:
  export CPPFLAGS="-I/opt/homebrew/opt/openjdk@17/include"
==> Analytics
install: 18,294 (30 days), 59,204 (90 days), 273,258 (365 days)
install-on-request: 15,800 (30 days), 49,966 (90 days), 180,903 (365 days)
build-error: 101 (30 days)

おっふXcodeないやんけ

==> Requirements
Build: Xcode (on macOS) ✘
% brew search Xcode
==> Formulae
xcode-build-server                xcode-kotlin                      xcodegen                          xcodes                            coder

==> Casks
copilot-for-xcode                 swiftformat-for-xcode             xcodeclangformat                  xcodes                            xscope

If you meant "Xcode" specifically:
Xcode can be installed from the App Store.

しゃあないAppStoreから落とすか

If you meant "Xcode" specifically:
Xcode can be installed from the App Store.

今度こそadd

$  jenv add /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home

動作確認

$ jenv versions
* system (set by /Users/sakamotokeika/.jenv/version)
  17.0
  17.0.9
  20.0
  20.0.2
  21.0
  21.0.2
  openjdk64-17.0.9
  openjdk64-20.0.2
  openjdk64-21.0.2

適当なディレクトリほって確認

$ jenv local 17.0.9

$ jenv versions
  system
  17.0
* 17.0.9 (set by /Users/sakamotokeika/dev/scala/.java-version)
  20.0
  20.0.2
  21.0
  21.0.2
  openjdk64-17.0.9
  openjdk64-20.0.2
  openjdk64-21.0.2

OK!

kotlin

$ brew install kotlin

一旦ここまで


gooye-g

初心者

所有者限定モードのためこのボードには投稿できません
コメント