https://github.com/jenv/jenv#readme
Installing jenv
On OSX, the simpler way to install jEnv is using Homebrew
brew install jenvAlternatively, and on Linux, you can install it from source :
1
2
3
4
5
6
7git clone https://github.com/jenv/jenv.git ~/.jenv
# Shell: bash
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(jenv init -)"' >> ~/.bash_profile
# Shell: zsh
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(jenv init -)"' >> ~/.zshrcnote: notice your Shell(zsh or bash), find regarding profile(~/.bash_profile or ~/.zshrc).
jenv doctorAdding Your Java Environment
jenv add $(/usr/libexec/java_home)add jdk to your jenv.
jenv add /Library/Java/JavaVirtualMachines/1.8.0.jdk/Contents/Home jdk1.8 addedCheck java versions.
1
2
3
4
5jenv versions
*system (set by /Users/user/.jenv/version)
11.0
11.0.2
openjdk64-11.0.2Setting a Java Version
1
2
3jenv global 11.0.2
jenv shell 11.0.2
jenv local 11.0.2Using two JVMs on MacOS
https://github.com/AdoptOpenJDK/homebrew-openjdk
latest:
1
brew cask install adoptopenjdk
Other Versions
1
2brew tap AdoptOpenJDK/openjdk
brew cask install <version>
This will install the latest version of Java 8 to a special directory in macOS. Let’s see which directory that is:
1
2
3ls -1 /Library/Java/JavaVirtualMachines
adoptopenjdk-8.jdk
openjdk-11.0.2.jdkWe’ll add the Java home directory using
jenv1
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/ openjdk64-1.8.0.222 added