简体   繁体   English

Eclipse认为我只有Java 1.6,但是在终端中检查Java版本时会显示1.7。 救命 :)

[英]Eclipse thinks I only have Java 1.6, but when checking java-version in terminal it displays 1.7. Help :)

I just downloaded Eclipse, and it said "Version 1.7 or greater is required" for Java. 我刚刚下载了Eclipse,它说Java“要求版本1.7或更高版本”。 Then I downloaded Java 1.7 and installed it and all that, and even restarted my computer. 然后,我下载并安装了Java 1.7,并重新启动了我的计算机。 When I check my Java version in the terminal, it says Java 1.7, so why can't Eclipse recognize Java 1.7? 当我在终端中检查Java版本时,它显示Java 1.7,那么Eclipse为什么不能识别Java 1.7?

Thanks a lot! 非常感谢! :) :)

My question isn't a duplicate of Running Eclipse on Mac - JVM Version 1.7 or greater is required because I installed the entire JDK 7 and my computer recognizes Java 1.7. 我的问题不是在Mac运行Eclipse的重复-JVM 1.7或更高版本是必需的,因为我安装了整个JDK 7,并且我的计算机可以识别Java 1.7。 Right now, I can't even open Eclipse. 现在,我什至无法打开Eclipse。

EDIT: current steps I have taken: 编辑:我已经采取的当前步骤:

1) finding the path (/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home) to java 1.7 with command "/usr/libexec/java_home -v 1.7" 1)使用命令“ / usr / libexec / java_home -v 1.7”找到到Java 1.7的路径(/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home)

2) pasting this path by adding the following in the eclipse.ini file, 2)通过在eclipse.ini文件中添加以下内容来粘贴此路径,

-vm -vm

/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home /图书馆/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

Error message is still: 错误消息仍然是:

Version 1.6.0_65 of the JVM is not suitable for this product. JVM的1.6.0_65版本不适用于此产品。 Version: 1.7 or greater is required. 版本:1.7或更高版本。

我确定您必须这样做,但以防万一您无法确保为Java设置了环境变量

Have you tried Window -> Preferences -> Java -> Installed JREs ? 您是否尝试过Window -> Preferences -> Java -> Installed JREs

There you can add (Using the Standard VM option) a JDK (or JRE) by setting the path to the JDK install directory. 您可以在此处通过设置JDK安装目录的路径来添加(使用Standard VM选项)JDK(或JRE)。

right click on 右键点击

project --> properties --> java compiler 项目->属性-> Java编译器

and see the jdk compiler compliance level option set to 1.7 compiler, if not change it to 1.7 or higher 并查看将jdk编译器符合性级别选项设置为1.7编译器(如果未将其更改为1.7或更高版本)

EDIT :- 编辑:-

eclipse by default will take java installation path from %JAVA_HOME% variable, firstly you check whether you have set JAVA_HOME path in your machine. eclipse默认情况下将从%JAVA_HOME%变量获取Java安装路径,首先检查您是否在计算机中设置了JAVA_HOME路径。

or you can manually set java path in eclipse.ini file as said in this post 或者您可以按照本文所述在eclipse.ini文件中手动设置Java路径

How do I set the Java path in Eclipse so I can run it on an external drive? 如何在Eclipse中设置Java路径,以便可以在外部驱动器上运行它?

and

How to specify jdk path in eclipse.ini on windows 8 when path contains space 当路径包含空格时如何在Windows 8的eclipse.ini中指定jdk路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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