Eclipse JDK设置如何影响系统的JDK设置 [英] How is the Eclipse JDK setting affecting the system's JDK setting

查看:168
本文介绍了Eclipse JDK设置如何影响系统的JDK设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Mac OSX上编译引用第三方JAR的Grails应用程序。虽然我的系统的JRE和JDK设置为Java 1.6我总是得到一个编译错误:java.lang.UnsupportedClassVersionError:.class文件中的错误版本号
JAR中的类。此外,当测试现有的Grails应用程序时,应用程序的默认统计信息显示它使用Java 1.6进行运行。所以我真的没有更多的想法,而不是尝试改变Eclipse中的Java设置 - 我认为这是愚蠢的,因为我没有使用Eclipse为这个应用程序的发展 - 但瞧 - 现在编译我的应用程序的命令线条工程很好!

I was trying to compile a Grails application referencing third party JARs on Mac OSX. Although my system's JRE and JDK is set to Java 1.6 I always got a Compilation error: java.lang.UnsupportedClassVersionError: Bad version number in .class file when accessing classes in the JAR. Also when testing an existing Grails app the default stats of the app where showing that it's running with Java 1.6. So I really didn't have more ideas than to try to change the Java settings in Eclipse - I thought that's stupid as I'm not using Eclipse for the devlopment of this application - but voila - now the compilation of my app on the command line works just fine!

任何人都可以解释我在幕后做什么Eclipse?
我以前手动设置了JAVA_HOME,没有任何效果。

Can anyone explain me what Eclipse is doing here behind the scenes? I've had set the JAVA_HOME manually before with no effect.

推荐答案

JDK(JAVA_HOME) eclipse不一定是用于编译您的项目的一个。

The JDK (JAVA_HOME) used to launched eclipse is not necessarily the one used to compiled your project.

要查看您可以为您的项目选择什么JRE,请查看偏好设置

To see what JRE YOU y can select for your project, check the preferences

General > Java Installed JRE

默认情况下,如果您没有添加任何JRE,则只有一个声明为一个用于启动eclipse(可以在您的中定义) eclipse.ini )。

您可以添加任何您想要的其他JRE,包括一个与您的项目。

By default, if you have not added any JRE, the only one declared will be the one used to launched eclipse (which can be defined in your eclipse.ini).
You can add any other JRE you want, including one compatible with your project.

之后,您需要办理入住手续您的项目属性(或一般偏好)中使用了什么JRE,具有什么合规级别:

After that, you will need to check in your project properties (or in the general preferences) what JRE is used, with what compliance level:

这篇关于Eclipse JDK设置如何影响系统的JDK设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆