ant 和 java 8 - “主要版本 52 比 51 新,这是此编译器支持的最高主要版本”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24106371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ant and java 8 - "major version 52 is newer than 51, the highest major version supported by this compiler"
提问by Eyal leshem
I am trying to upgrade my ant project from java 7 to java 8.
(the project deployed in "Eclipse Kepler" with "Java? 8 support to Eclipse Kepler SR2")
我正在尝试将我的 ant 项目从 java 7 升级到 java 8。
(该项目部署在“Eclipse Kepler”中,“Java?8 支持 Eclipse Kepler SR2”)
For that i downloaded ant 1.9.4 ( according this post http://wiki.eclipse.org/Ant/Java8) , and configure it's as my "ant home".
为此,我下载了 ant 1.9.4(根据这篇文章http://wiki.eclipse.org/Ant/Java8),并将其配置为我的“蚂蚁之家”。
when i am trying to compile a got the following warning:
"major version 52 is newer than 51, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded."
当我尝试编译时收到以下警告:
"major version 52 is newer than 51, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded."
But the compiler that defined for the workspace is 1.8. (In the ant configuration it's define the compiler to be the same compiler of the work space..)
但是为工作区定义的编译器是 1.8。(在 ant 配置中,它将编译器定义为与工作空间相同的编译器..)
Any idea whats happened?
知道发生了什么吗?
Thanks a lot.
非常感谢。
Eyal
艾尔
采纳答案by M Anouti
Please check that the tools.jar used by Ant is from JDK8 and not JDK7.
请检查 Ant 使用的 tools.jar 是否来自 JDK8 而不是 JDK7。
Window -> Preferences:
窗口 -> 首选项:
In the left pane, go to Ant -> Runtime. In the Classpath tab, check the Global Entries.
在左窗格中,转到 Ant -> Runtime。在 Classpath 选项卡中,检查 Global Entries。
回答by Amz
This error usually comes when there is difference in the JDK version.Please check classpath, java -version and JAVA_HOME set in the environment variable.
这个错误一般出现在JDK版本不同时。请检查环境变量中设置的classpath、java -version和JAVA_HOME。
回答by sangress
Make sure to add JAVA_HOME in the Classpath variables: Window->Java->Build Path->Classpath variables point to "path/to/jdk"
确保在Classpath变量中添加JAVA_HOME:Window->Java->Build Path->Classpath variables point to "path/to/jdk"
回答by Fruit
In Ubuntu, I simply fixed it by configure javah
from jdk(either openjdk or oracle jdk works) 7 to 8:
在 Ubuntu 中,我只是通过配置javah
从 jdk(openjdk 或 oracle jdk 工作)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
$