将 Eclipse ant 降级以在使用较旧的 JDK 库时进行编译(Java 1.7 -> 1.6) [英] Downgrade Eclipse ant to compile while using older JDK libraries (Java 1.7 -> 1.6)

查看:29
本文介绍了将 Eclipse ant 降级以在使用较旧的 JDK 库时进行编译(Java 1.7 -> 1.6)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与升级Eclipse java编译器相反的问题:我正在使用Eclipse 3.7.1 可以支持 JDK 1.7,但现在我正在为 JDK 1.6 开发......它一直工作正常,但是当我进行 ant 构建时突然出现了大量这样的错误(见下文).

I have the opposite problem as Upgrade Eclipse java compiler: I'm using Eclipse 3.7.1 that can support JDK 1.7, but right now I am developing for JDK 1.6... which has been working fine, but suddenly I'm getting tons of errors like this when I do an ant build (see below).

我想使用 JDK 1.6;我在哪里设置?Eclipse 设置正确(每个项目的Java Build Path 指向JRE System Library [jdk1.6.0_16]),但是ant 似乎不理会它.

I want to use JDK 1.6; where do I set that? Eclipse is set properly (Java Build Path for each project points to JRE System Library [jdk1.6.0_16]), but ant seems to be disregarding it.

[javac] warning: java\nio\ByteBuffer.class(java\nio:ByteBuffer.class): major version 51 is newer than 50, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\lang\Object.class(java\lang:Object.class): major version 51 is newer than 50, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\Collections.class(java\util:Collections.class): major version 51 is newer than 50, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.
[javac] warning: java\util\EnumMap.class(java\util:EnumMap.class): major version 51 is newer than 50, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.

<小时>

更新:更多线索——这是我第一次在单独的 Eclipse 工作区中构建这个特定项目,该工作区从以前的工作区导入项目.我切换回旧工作区并构建了相同的项目,它构建得很好.


update: More clues -- this is the first time I've built this particular project in a separate Eclipse workspace that imports the project from a previous workspace. I switched back to the old workspace and built the same project and it builds fine.

不同之处似乎是 ant 在我的新工作区中以 1.7 JRE 运行,但 ant 在我旧工作区中以 1.6 JRE 运行.是什么赋予了?我在哪里设置这个?我似乎无法弄清楚哪个设置不同.

The difference seems to be that ant runs in a 1.7 JRE in my new workspace, but ant runs in a 1.6 JRE in my old workspace. What gives? Where do I set this? I can't seem to figure out which setting is different.

推荐答案

找到了:

在 Eclipse 的 Ant 选项卡中,如果您右键单击您的构建,然后单击 Run As -> Ant Build...,则会弹出一个编辑配置"对话框,您可以选择哪个 JRE您想用于 Ant.

In the Ant tab in Eclipse, if you right-click on your build, and click Run As -> Ant Build..., then it will pop up an "Edit Configuration" dialog box, and you can select which JRE you want to use for Ant.

我不知道此设置存储在哪里,但它似乎存储在工作区中,而不是与项目设置一起存储.

I don't know where this setting is stored, but it appears to be stored in the workspace rather than with the project settings.

这篇关于将 Eclipse ant 降级以在使用较旧的 JDK 库时进行编译(Java 1.7 -> 1.6)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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