How do I install Java on Mac OSX allowing version switching?

后端 未结 10 850
暖寄归人
暖寄归人 2020-12-22 14:37

I want to install OpenJDK Java on Mac OSX and have it work alongside other JDK\'s since it is a newer release. Currently, I downloaded the tar.gz and placed it in my path b

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-22 15:07

    You can use asdf to install and switch between multiple java versions. It has plugins for other languages as well. You can install asdf with Homebrew

    brew install asdf
    

    When asdf is configured, install java plugin

    asdf plugin-add java
    

    Pick a version to install

    asdf list-all java
    

    For example to install and configure adoptopenjdk8

    asdf install java adoptopenjdk-8.0.272+10
    asdf global java adoptopenjdk-8.0.272+10
    

    And finally if needed, configure JAVA_HOME for your shell. Just add to your shell init script such as ~/.zshrc in case of zsh:

    . ~/.asdf/plugins/java/set-java-home.zsh
    

提交回复
热议问题