brew install jenv
- Add following configs into
~/.bash_profile
or~/.bashrc
or~/.zshrc
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
- restart shell
- if using zsh
source ~/.zshrc
- if using zsh
jenv doctor
- ensure that JAVA_HOME is correct
jenv enable-plugin export
- make Maven aware of the java version in use & switch when project does
jenv enable-plugin maven
- Install latest
brew install openjdk
- Install Java 7
brew install --cask homebrew/cask-versions/zulu7
- Install Java 8
brew install AdoptOpenJDK/openjdk/adoptopenjdk8
- Install Java 9
brew install AdoptOpenJDK/openjdk/adoptopenjdk9
- Install Java 10
brew install AdoptOpenJDK/openjdk/adoptopenjdk10
- Install Java 11
brew install AdoptOpenJDK/openjdk/adoptopenjdk11
- list all java versions installed
/usr/libexec/java_home -V
- if installed java version path is not listed, find the path, then add it with the same method below
- Add JDK path
jenv add <your_jdk_path>
- e.g.:
jenv add /Library/Java/JavaVirtualMachines/openjdk-14.0.1.jdk/Contents/Home
- e.g.:
jenv versions
jenv global 14.0
jenv local 11
- this will create a
.java-version
file inside the current folder
jenv shell openjdk64-1.8.0.252
java -version