How to set or change the default Java (JDK) version on OS X?

后端 未结 28 2730
渐次进展
渐次进展 2020-11-22 15:55

How can you change the default version of Java on a mac?

28条回答
  •  广开言路
    2020-11-22 16:03

    install JDK, not just JRE

    /usr/libexec/java_home -v 1.8
    

    gives

    /Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
    

    next

    touch .bash_profile
    
    open -a TextEdit.app .bash_profile
    

    TextEdit will show you a blank page which you can fill in.

    add to doc: export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home

    in terminal:

    export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
    

    try the command:

    javac -version

    should output:

    javac 1.8.0_111
    

提交回复
热议问题