我安装了 Java 7 但 Eclipse 一直说 1.6 不适合这个产品

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25102627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 23:38:54  来源:igfitidea点击:

I installed Java 7 but Eclipse keep saying that 1.6 is not suitable for this product

javaeclipsemacos

提问by Anishka Jitendrabhai Vaghani

I'm using latest version of Eclipse Luna on Mac OS X 10.9.4. Whenever I try to open the Eclipse it says "version 1.6.0_65 of the JVM is not suitable for this product, version 1.7 or greater is required". I installed java 7 (JRE, I don't need JDK) but still I'm getting the same error. I tried java -version and the output was "java version 1.6.0_65". I can see the java icon on my system preferences. I also restarted my Mac to see if that works but that doesn't help either. I searched on google and some people suggesting other users to change Eclipse.ini file, the instructions wasn't clear and I'm a java beginner so I've no idea where and what to edit. Any step by step instructions will be appreciated.

我在 Mac OS X 10.9.4 上使用最新版本的 Eclipse Luna。每当我尝试打开 Eclipse 时,它​​都会说“JVM 的 1.6.0_65 版不适合此产品,需要 1.7 版或更高版本”。我安装了 java 7(JRE,我不需要 JDK)但仍然遇到相同的错误。我试过 java -version 并且输出是“java version 1.6.0_65”。我可以在我的系统首选项中看到 java 图标。我还重新启动了我的 Mac 以查看它是否有效,但这也无济于事。我在谷歌上搜索,有些人建议其他用户更改 Eclipse.ini 文件,说明不清楚,而且我是一个 Java 初学者,所以我不知道在哪里编辑和编辑什么。任何分步说明将不胜感激。

采纳答案by MWiesner

A potential solution to your problem might be to uninstall Java6 (provided by Apple itself) and only have Java7 installed in your system. This only applies in case you have no applications that desperately need the old Java6 version to be installed.

您的问题的一个潜在解决方案可能是卸载 Java6(由 Apple 自己提供)并且只在您的系统中安装 Java7。这仅适用于您没有迫切需要安装旧 Java6 版本的应用程序的情况。

To remove the Apple-like Java6 installation open a Terminal and:

要删除类似 Apple 的 Java6 安装,请打开一个终端,然后:

sudo rm -rf /System/Library/Java/JavaVirtualMachines/1.6.0.jdk

须藤 rm -rf /System/Library/Java/JavaVirtualMachines/1.6.0.jdk

After this step you should only have Java7 by Oracle installed in your system. To verify, open another terminal and do a:

在这一步之后,您的系统中应该只安装了 Oracle 的 Java7。要验证,请打开另一个终端并执行以下操作:

java -version

版本

It should display something like "java version "1.7.0_XX" where XX is the current update version of the Java7 installation. If not: proceed with the next step.

它应该显示类似“java version "1.7.0_XX”的内容,其中 XX 是 Java7 安装的当前更新版本。如果不是:继续下一步。

Redefine the JAVA_HOME variable (to support IDEs like Eclipse and other developer tools...), which helps detecting where the "active" Java installation is situated in your system. Open a terminal and (Note: replace XX first!):

重新定义 JAVA_HOME 变量(以支持 IDE 之类的 Eclipse 和其他开发人员工具...),这有助于检测“活动”Java 安装在系统中的位置。打开终端和(注意:先替换 XX!):

sudo rm /Library/Java/Home

sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_XX.jdk/Contents/Home /Library/Java/Home

sudo rm /Library/Java/Home

sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_XX.jdk/Contents/Home /Library/Java/Home

Afterwards, a fresh installation of Eclipse should detect Java7 in your system and should work with this version out of the box. You can modify an installed Eclipse to use this installation by navigating in Eclipse to:

之后,全新安装的 Eclipse 应该会在您的系统中检测到 Java7,并且应该可以开箱即用地使用该版本。您可以通过在 Eclipse 中导航到以下位置来修改已安装的 Eclipse 以使用此安装:

Preferences -> Java -> Installed JREs. Then remove the old Java6 system entry AND add new path (see above) with the name Java7.

首选项 -> Java -> 已安装的 JRE。然后删除旧的 Java6 系统条目并添加名为 Java7 的新路径(见上文)。

回答by spoko

Check your system variables ($JAVA_HOME specifically). This may be helpful:
http://www.mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/

检查您的系统变量(特别是 $JAVA_HOME)。这可能会有所帮助:http:
//www.mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/

回答by VenomVendor

To specify Java 6 for OS X:

为 OS X 指定 Java 6:

-vm

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java

-vm

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java

For versions of Mac OS X 10.7+ the location has changed to

对于 Mac OS X 10.7+ 版本,位置已更改为

/Library/Java/JavaVirtualMachines/<''jdk_name_ver''>/Contents/Home/...

/Library/Java/JavaVirtualMachines/<''jdk_name_ver''>/Contents/Home/...

eclipse.ini > Specifying the JVM

eclipse.ini > 指定 JVM

Try any of these solutions

尝试这些解决方案中的任何一个

How do I run Eclipse using Oracle's new 1.7 JDK for the Mac?

如何使用适用于 Mac 的 Oracle 新 1.7 JDK 运行 Eclipse?

Mountain Lion with Java 7 only

仅限 Java 7 的 Mountain Lion

Eclipse still using java 6 as jre on Mac OSX

Eclipse 在 Mac OSX 上仍然使用 java 6 作为 jre

回答by rasolog

You can modify Info.plist inside Eclipse.app (right clic on Eclipse.app --> show package contents) and specify -vm after <key>Eclipse</key>.

您可以在 Eclipse.app 中修改 Info.plist(在 Eclipse.app 上右键单击 --> 显示包内容)并在 之后指定 -vm <key>Eclipse</key>

For example :

例如 :

<key>Eclipse</key>
    <array>
        <string>-vm</string><string>/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/bin/java</string>
        <string>-keyring</string><string>~/.eclipse_keyring</string>
        <string>-showlocation</string>
    </array>

回答by floatingpoint

I had this same problem with a fresh install of Eclipse Mars on OSX. I had installed the JRE from https://java.com/en/download/(which is the top google search result for "java download" for me.

我在 OSX 上全新安装 Eclipse Mars 时遇到了同样的问题。我已经从https://java.com/en/download/安装了 JRE (对我来说,这是“java 下载”的顶级谷歌搜索结果。

This failed for me with the same message "version 1.6.0_65 of the JVM is not suitable for this product, version 1.7 or greater is required"

这对我来说失败了,并显示相同的消息“JVM 的 1.6.0_65 版不适合此产品,需要 1.7 版或更高版本”

Then I saw a comment that I should get the JRE/JDK from oracle instead:

然后我看到一条评论说我应该从 oracle 获取 JRE/JDK:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

http://www.oracle.com/technetwork/java/javase/downloads/index.html

After downloading the most recent JDK from Oracle Eclipse starts fine.

从 Oracle Eclipse 下载最新的 JDK 后启动正常。

回答by VinayBS

As I found out, we don't need to un-install an existing Java 1.6. Just installing or deploying a newer version 1.7 or 1.8, and setting the JAVA_HOME, along with the below given activities will solve the issue.

正如我发现的,我们不需要卸载现有的 Java 1.6。只需安装或部署较新的 1.7 或 1.8 版本,并设置 JAVA_HOME 以及以下给定的活动即可解决问题。

Check your c:/Windows/System32 (as I had this issue in windows). You will find junk java processes (java.exe, javaws.exe etc). Delete them all.

检查您的 c:/Windows/System32(因为我在 Windows 中遇到了这个问题)。您会发现垃圾 java 进程(java.exe、javaws.exe 等)。将它们全部删除。

Deleting just java.exe will reflect in your PATH but eclipse still picks the javaws from c:/windows/system32. This is because, usually in PATH, you will have C:/Windows/System32 as the first entry. So, this will override any JAVA_HOME entry in the path.

仅删除 java.exe 将反映在您的 PATH 中,但 Eclipse 仍会从 c:/windows/system32 中选择 javaws。这是因为,通常在 PATH 中,您会将 C:/Windows/System32 作为第一个条目。因此,这将覆盖路径中的任何 JAVA_HOME 条目。

Try starting the eclipse. It should work like charm! Atleast it did for me.

尝试启动日食。它应该像魅力一样工作!至少它对我有用。

回答by Rajesh Kumar

I see that you have installed the Java plugin and not the jdk. You can download the JDK from Oracle Downloads section.

我看到您安装的是 Java 插件而不是 jdk。您可以从 Oracle 下载部分下载 JDK。

You can remove the Java Plugin and install JDK from oracle downloads to resolve your issue.

您可以从 oracle 下载中删除 Java 插件并安装 JDK 以解决您的问题。

回答by ranbuch

  1. Install the updated JDK
  2. Update the environment variables: here's how
  3. If still not working uninstall the older JDK
  1. 安装更新的 JDK
  2. 更新环境变量:方法如下
  3. 如果仍然无法正常工作,请卸载旧版 JDK

回答by John

I have had the same problem as noted above. I could not get Eclipse to install because of Java incompatibilities. The sequence I followed goes like this:

我遇到了与上述相同的问题。由于 Java 不兼容,我无法安装 Eclipse。我遵循的顺序是这样的:

  1. Upgraded to MAC OS Sierra

  2. Downloaded the Eclipse installer but was prompted that I needed to instal a legacy Java.Installed Java 1.6

  3. Was unable to install Eclipse and was prompted that I needed Java 1.7 or greater. Downloaded and installed Java 1.8 Ran the terminal code 'java -version' // this will check your jre version. This showed returned Java 1.6 despite the fact that I had upgraded to 1.8. The Java version listed in the Java control panel said 1.8

  4. Tried multiple downloads of eclipse and Java and multiple restarts always with the same result.

  5. Visited the Oracle web page. I could not find the above reference to 8u73 and 8u74 but I did find and option to download 1.8.0_12. I did this. It installed without difficulty, and then I was able to install Eclipse without difficulty.

  1. 升级到 MAC OS Sierra

  2. 下载了 Eclipse 安装程序,但提示我需要安装旧版 Java.Installed Java 1.6

  3. 无法安装 Eclipse 并提示我需要 Java 1.7 或更高版本。下载并安装 Java 1.8 运行终端代码 'java -version' // 这将检查您的 jre 版本。尽管我已升级到 1.8,但这显示返回了 Java 1.6。Java 控制面板中列出的 Java 版本显示为 1.8

  4. 尝试多次下载 eclipse 和 Java,多次重启总是得到相同的结果。

  5. 访问了 Oracle 网页。我找不到上面对 8u73 和 8u74 的引用,但我确实找到了下载 1.8.0_12 的选项。我这样做了。它没有困难地安装,然后我能够毫无困难地安装 Eclipse。