降级 Eclipse ant 以在使用较旧的 JDK 库时进行编译(Java 1.7 -> 1.6)
我有与 升级 Eclipse java 编译器相反的问题:我正在使用 Eclipse 3.7.1 可以支持 JDK 1.7,但现在我正在为 JDK 1.6 进行开发...它运行良好,但是当我进行 ant 构建时突然遇到大量这样的错误 (见下文)。
我想使用JDK 1.6;我在哪里设置呢? Eclipse 设置正确(每个项目的 Java 构建路径都指向 JRE 系统库 [jdk1.6.0_16]),但 ant 似乎忽略它。
[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 工作区中构建这个特定的项目,该工作区从以前的工作区导入该项目。我切换回旧的工作区并构建了相同的项目,并且构建得很好。
区别似乎在于 ant 在我的新工作区中运行在 1.7 JRE 中,但 ant 在我的旧工作区中运行在 1.6 JRE 中。什么给?我在哪里设置这个?我似乎无法弄清楚哪个设置不同。
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).
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.
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到它:
在 Eclipse 的 Ant 选项卡中,如果右键单击您的构建,然后单击 Run As -> Ant Build...,然后会弹出一个“编辑配置”对话框,您可以选择要用于 Ant 的 JRE。
我不知道此设置存储在哪里,但它似乎存储在工作区中而不是与项目设置一起存储。
found it:
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.