Not able to change the JDK in Mac OS using Jenv

前端 未结 3 1575
轻奢々
轻奢々 2021-01-28 05:46

I am using Amazon corretto JDK and earlier had only 1.8 installed in my Mac OS, yesterday I installed Amazon corretto JDK 11 using the Mac OS package installer and after that it

3条回答
  •  不思量自难忘°
    2021-01-28 06:41

    Try adding this to your .bash_profile or .zshrc or .bashrc whatever is relevant to your macOS.

    jdk() {
            version=$1
            export JAVA_HOME=$(/usr/libexec/java_home -v"$version");
            java -version
     }
    

    Then, restart terminal and you can switch java versions like:

    • jdk 1.8
    • jdk 11

提交回复
热议问题