简体   繁体   中英

Can't install Java 1.8 on my mac

so here is my problem : I wanted to install Eclipse on my Macbook Pro to code in Java. However when I launch the Eclipse Install I have a popup saying :

Version 1.6.0_65 of the JVM is not suitable for this product.
Version: 1.8 or greater is required.

So I went on the java website to install the latest version of java, which is the version 8 update 121. Then I got a dmg file and started installing it. Everything worked fine and the installation finished. I tried to restart the Eclipse Install but the same popup still showed up. I went to the System Preferences in the Java section and it says that I have the latest version installed, which is 8 update 121.

After searching a little on the internet, I checked the version in the Command Line :

$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)

Apparently I have to tell java_home to use the last version with the command :

$ /usr/libexec/java_home -v jdk1.8.0_121 --exec javac -version

However I get :

Unable to find any JVMs matching version "jdk1.8.0_121".

So I also checked which versions I had :

$  /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.6.0_65-b14-468, x86_64:   "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-468, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

As you can see the version 1.8.0 is not here. I tried to look into the file directory to find the folder in /library/Java/JavaVirtualMachines, but there is only the folder "1.6.0 jdk".

So my question is where is Java ? Why does the System Preferences say I'm at 1.8 and the Command Line says 1.6 ? How do I install it properly in order to install Eclipse ? If it helps I have a Macbook Pro 2012 on macOS Sierre 10.12.2

Thanks

You have almost certainly only installed the Java 8 JRE . On macOS this only installs Java plug-ins support in the browser. To get full Java 8 support you must install the full JDK ('jdk-8u121-macosx-x64.dmg' is the current version of the JDK).

First do a clean install of java by following the below steps for uninstalling and re installing java.

To do clean uninstall:

1. Click on the Finder icon located in your dock
2. Click on the Utilities folder
3. Double-click on the Terminal icon
4. In the Terminal window Copy and Paste the commands below:
     sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
     sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
     sudo rm -fr ~/Library/Application\ Support/Java

Then do a reinstallation of java 8 by using the link,

https://www.java.com/en/download/help/mac_install.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM