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

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

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

28条回答
  •  庸人自扰
    2020-11-22 16:14

    From the Apple's official java_home(1) man page:

    **USAGE**
    
       /usr/libexec/java_home  helps  users  set a $JAVA_HOME in their login rc files, or provides a way for
       command-line Java tools to use the most appropriate JVM which can satisfy a minimum version or archi-
       tecture  requirement.  The --exec argument can invoke tools in the selected $JAVA_HOME/bin directory,
       which is useful for starting Java command-line tools from launchd plists without hardcoding the  full
       path to the Java command-line tool.
    
       Usage for bash-style shells:
              $ export JAVA_HOME=`/usr/libexec/java_home`
    
       Usage for csh-style shells:
              % setenv JAVA_HOME `/usr/libexec/java_home`
    

提交回复
热议问题