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

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

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

28条回答
  •  猫巷女王i
    2020-11-22 16:27

    Four easy steps using terminal for people who uses the default process.. :)

    1. echo $JAVA_HOME gives you current java home. For eg: /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/

    2. cd /Library/Java/JavaVirtualMachines/ will take you to the folder where u normally install jdks (It might be different for your machines)

    3. ls shows you available folders (normally it will have the version numbers, for eg: jdk1.8.0_191.jdk openjdk-11.0.2.jdk)
    4. export JAVA_HOME='/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home' will change the java home..

提交回复
热议问题