How to downgrade Java from 9 to 8 on a MACOS. Eclipse is not running with Java 9

前端 未结 7 1062
野的像风
野的像风 2020-12-02 04:27

How to downgrade Java from 9 to 8 on a macOS Sierra 10.12.6(16G29) . I tried removing the Java plugin and installed Java 8, however the Java and javac version shows 9 in ter

7条回答
  •  死守一世寂寞
    2020-12-02 04:38

    If you have multiple Java versions installed on your Mac, here's a quick way to switch the default version using Terminal. In this example, I am going to switch Java 10 to Java 8.

    $ java -version
    java version "10.0.1" 2018-04-17
    Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
    Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
    
    $ /usr/libexec/java_home -V
    Matching Java Virtual Machines (2):
        10.0.1, x86_64: "Java SE 10.0.1"    /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
        1.8.0_171, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
    
    /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
    

    Then, in your .bash_profile add the following.

    # Java 8
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
    

    Now if you try java -version again, you should see the version you want.

    $ java -version
    java version "1.8.0_171"
    Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
    Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
    

提交回复
热议问题