Ant 和 Java 8 - "major version 52 is newer than 51, the highest major version supported by this compi



我正在尝试将我的ant项目从java 7升级到java 8。
(项目部署在"Eclipse Kepler"中,"Java™8支持Eclipse Kepler SR2")

为此,我下载了ant 1.9.4(根据这个帖子http://wiki.eclipse.org/Ant/Java8),并将其配置为我的"ant home"。

当我试图编译a时,得到以下警告: "major version 52 is newer than 51, the highest major version supported by this compiler. [javac] It is recommended that the compiler be upgraded."

但是为工作空间定义的编译器是1.8。(在ant配置中,它将编译器定义为与工作空间相同的编译器..)

知道发生了什么事吗?

非常感谢。

Eyal

请检查Ant使用的tools.jar是否来自JDK8,而不是JDK7。

Window -> Preferences:

在左侧窗格中,转到Ant -> Runtime。在Classpath选项卡中,检查全局条目。

此错误通常在JDK版本不同时出现。

请检查环境变量中的classpath, java -version和JAVA_HOME设置。

确保在Classpath变量中添加JAVA_HOME: Window->Java->Build Path->Classpath变量指向" Path/to/jdk"

在Ubuntu中,我简单地通过从jdk(openjdk或oracle jdk works)配置javah来修复它7到8:

$ javah -classpath . -d jni/ NativeSorting
./NativeSorting.class: major version 52 is newer than 51, the highest major version supported by this compiler.
  It is recommended that the compiler be upgraded.
$ sudo update-alternatives --config javah
There are 4 choices for the alternative javah (providing /usr/bin/javah).
  Selection    Path                                         Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-openjdk-amd64/bin/javah   1081      auto mode
* 1            /usr/lib/jvm/java-7-openjdk-amd64/bin/javah   1071      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/bin/javah   1081      manual mode
  3            /usr/lib/jvm/jdk1.7.0_80/bin/javah            1000      manual mode
  4            /usr/lib/jvm/jdk1.8.0_131/bin/javah           1000      manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/javah to provide /usr/bin/javah (javah) in manual mode
$ javah -classpath . -d jni/ NativeSorting
$ 

添加到所有其他答案:为我解决这个问题的是在PATH环境变量中删除冗余/不同的java路径。

相关内容

  • 没有找到相关文章

最新更新