Skip to content

Latest commit

 

History

History
105 lines (71 loc) · 1.67 KB

Multiple_Java_Versions_in_MacOS.md

File metadata and controls

105 lines (71 loc) · 1.67 KB

Multiple Java Versions in MacOS

Mac에서 여러개의 Java version을 관리하기

References: jenv.be, how-to-manage-multiple-java-version-in-macos



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

brew install java

# For older Java versions, use this command
brew install AdoptOpenJDK/openjdk/adoptopenjdk{11,14}

# or you can install a single version as follows:
brew install AdoptOpenJDK/openjdk/adoptopenjdk8

See all the installed JDK versions in your machine

/usr/libexec/java_home -V

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

jenv add <your_jdk_path>

# Example:
jenv add /Library/Java/JavaVirtualMachines/openjdk-14.0.1.jdk/Contents/Home

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

jenv versions

Setting system-wide Java version

jenv global 11

Setting project-wide Java version

jenv local 8

Setting shell instance Java version

jenv shell openjdk64-1.8.0.252

Checking current Java version

java -version