Manage multiple jdks in macos, M1
First, install jenv
by using Homebrew
1 | brew install jenv |
After that, need to config the zsh
1 | echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc |
It only found the system default Java:
1 | jenv versions |
Add the jdk you installed to the jenv. Personally my jdks are installed at /Users/klam/Library/Java/JavaVirtualMachines/
For example:
jenv add /Users/klam/Library/Java/JavaVirtualMachines/azul-17.0.3/Contents/Home/
jenv global 17
to swap between different jdk for the default jdk
you can also use jenv local 17
to specifies the Java version of a folder