jenv多版本jdk

https://www.jenv.be/

下载

brew install jenv

Installation

Bash
$ echo ‘export PATH=”$HOME/.jenv/bin:$PATH”‘ >> ~/.bash_profile
$ echo ‘eval “$(jenv init -)”‘ >> ~/.bash_profile
Zsh
$ echo ‘export PATH=”$HOME/.jenv/bin:$PATH”‘ >> ~/.zshrc
$ echo ‘eval “$(jenv init -)”‘ >> ~/.zshrc

Configure

$ jenv add /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
oracle64-1.6.0.39 added
$ jenv add /Library/Java/JavaVirtualMachines/jdk17011.jdk/Contents/Home
oracle64-1.7.0.11 added

source .zshrc

Use

List managed JDKs

$ jenv versions
system
oracle64-1.6.0.39

  • oracle64-1.7.0.11 (set by /Users/hikage/.jenv/version)

Configure global version

$ jenv global oracle64-1.6.0.39

Configure local version (per directory)

$ jenv local oracle64-1.6.0.39

Configure shell instance version

$ jenv shell oracle64-1.6.0.39

每次切换版本要source .zshrc