Eclipse in OS X uses different version of Java tha

2020-02-07 00:21发布

When I type java -version in the console I get java version "1.8.0_05". The soft link /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK points to /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents. In the java preferences window, the only listed version of Java is 1.8. JAVA_HOME is set to /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home.

However, when I try to run Eclipse.app, I get the error: Version 1.6.0_65 of the JVM is not suitable for this product. Version: 1.7 or greater required.

I believe it is trying to use /System/Library/Java/JavaVirtualMachines and in that directory the only version is 1.6.0.jdk.

How can I get eclipse to use the correct version of Java?

6条回答
时光不老,我们不散
2楼-- · 2020-02-07 00:42

I faced this same problem but rather than making it to use version 1.8 I changed the settings in eclipse.ini file so I can just run the program regardless which version of jvm does it want to use

Solution:

Open the directory where you have Eclipse copy in your computer.

You would see a file name eclipse press control key and click on it to see the options.

Then click on Show Originalfrom the options, there you would find eclipse.ini file open it with a text editor and change the -Dosgi.requiredJavaVersion=1.7 to -Dosgi.requiredJavaVersion=1.6

Save the file and open the ecplise.app it should open now without any error

查看更多
▲ chillily
3楼-- · 2020-02-07 00:51

Download the 64-bit version of Eclipse instead of the 32-bit version.

The reason is that Eclipse contains native machine code (for the GUI) which is why there is both a 32-bit and 64-bit version of Eclipse, and this explicitly require the corresponding Java version. Originally Apple created both versions up to Java 6, but Oracle only creates a 64-bit version (much to the dismay of owners of older machines). So, if you download a 32-bit version of Eclipse it will only run with an Apple JVM, which apparently is too old (which surprise me - I thought Java 6 was still supported for Eclipse 4.4)

查看更多
虎瘦雄心在
4楼-- · 2020-02-07 00:51

Download the 64-bit version of Eclipse.

This solved the problem. Thanks everyone.

查看更多
疯言疯语
5楼-- · 2020-02-07 00:52

Take a look in your System Preferences -> Java. It should open the Java Control Panel. In the panel, check if you have one (or many) JDKs.

I suspect you have many and are setting the JDK in your .profile while Eclipse is reading some other Java Home.

You can change them manually by running this in your terminal

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

To check if it worked, run java -version and you should see something like

java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

Try calling Eclipse now from the command line. To call Eclipse as an App, just set the Java8 through the Java Control Panel. This will be read when Eclipse starts.

This is what I have on my Java Control Panel:

enter image description here

This is on my Eclipse Luna:

enter image description here

查看更多
手持菜刀,她持情操
6楼-- · 2020-02-07 01:02

I solved this issue in my mac with yosemite:

  1. Installed JDK for MACOSX 64bits from https://jdk8.java.net/download.html
  2. Inside the eclipse.ini I put this line:

    -vm /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home

And it worked for me!

查看更多
够拽才男人
7楼-- · 2020-02-07 01:07

Try adding the following lines to your eclipse.ini:

-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home

Maybe a newer version of eclipse could help, too (if yours is out of date).

查看更多
登录 后发表回答