Multiple Java Versions in MacOS

Managing multiple Java versions on Mac

References: jenv.bearrow-up-right, how-to-manage-multiple-java-version-in-macosarrow-up-right

Install Java version manager - jenv

brew install jenv

Add followings to shell config file - ~/.zshrc

export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"

And then run source ~/.zshrc of course

Run following commands (if you are using maven)

# ensure that JAVA_HOME is correct
jenv enable-plugin export
# make Maven aware of the Java version in use (and switch when your project does)
jenv enable-plugin maven

Install different JDK versions

See all the installed JDK versions in your machine

Add to jEnv each of the JDK you installed by the following command

See whether all the versions you add are available in the jEnv

Setting system-wide Java version

Setting project-wide Java version

Setting shell instance Java version

Checking current Java version

Last updated