gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:08:57 26 4
gpt4 key购买 nike

我遇到的问题与 Upgrade Eclipse java compiler 相反: 我正在使用 可以 支持 JDK 1.7 的 Eclipse 3.7.1,但现在我正在为 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选项卡中,如果你右击你的build,然后点击Run As -> Ant Build...,然后它会弹出一个“Edit Configuration”对话框,你可以选择哪个JRE您想用于 Ant。

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

关于java - 降级 Eclipse ant 以在使用较旧的 JDK 库时进行编译 (Java 1.7 -> 1.6),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8648842/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com