My take on JDK switchers for macOS
https://github.com/deluan/macos-jdk.git
A JDK switcher for macOS
.bashrc/.zshrc and you're all set.
.zshrc
zplug "deluan/macos-jdk"
Include the load command in your .zshrc
zgen load deluan/macos-jdk
zgen save
Bundle macos-zsh in your .zshrc
antigen bundle deluan/macos-jdk
antigen apply
Clone macos-jdk into your custom plugins repo
git clone https://github.com/deluan/macos-jdk $ZSH_CUSTOM/plugins/macos-jdk
Then load as a plugin in your .zshrc
plugins+=(macos-jdk)
Show all installed versions
$ jdk
Select a specific version (only valid for current session)
$ jdk 8
To set the default jdk to be used in your system, create a ~/.jdkversion file with the version number in it