降级 Eclipse ant 以在使用旧版 JDK 库时进行编译 (Java 1.7 -> 1.6)

2024-02-27

我有相反的问题升级Eclipse java编译器 https://stackoverflow.com/questions/4267760/upgrade-eclipse-java-compiler:我正在使用 Eclipse 3.7.1can支持 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 中。是什么赋予了?我在哪里设置这个?我似乎无法弄清楚哪个设置不同。


找到了:

在 Eclipse 的 Ant 选项卡中,如果右键单击您的构建,然后单击 Run As -> Ant Build...,则会弹出“编辑配置”对话框,您可以选择要使用的 JRE用于蚂蚁。

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

降级 Eclipse ant 以在使用旧版 JDK 库时进行编译 (Java 1.7 -> 1.6) 的相关文章

随机推荐