未找到 javac1.8 类 [英] javac1.8 class not found
问题描述
我已经安装了两个 jdk - jdk 1.5 和 jdk 1.8.我有以下 Ant build.xml 配置文件:
I have installed two jdks - jdk 1.5 and jdk 1.8. I have following Ant build.xml config file :
<target name="compileCustomSrc">
<javac srcdir="src" destdir="build/classes" source="1.5" target="1.5" >
<classpath>
<fileset dir="C:/lib/">
<include name="*.jar" />
</fileset>
</classpath>
</javac>
</target>
在安装 jdk1.8 之前,从 Eclipse 调用 Ant 编译所有源代码成功.但是现在,我有以下错误消息:
Before installing jdk1.8, Ant invoked from Eclipse compiled all sources successful. But now, I have following error message:
Class not found: javac1.8
我的 JAVA_HOME 和 JRE_HOME:
My JAVA_HOME and JRE_HOME:
JAVA_HOME = C:\Program Files (x86)\Java\jdk1.5.0_16
JRE_HOME = C:\Program Files (x86)\Java\jre1.5.0_16
并在 Eclipse JRE 中设置为 1.5.Java 1.8 在安装过程中是否设置了一些配置?
and set in Eclipse JRE to 1.5. Does Java 1.8 set some configs during installation?
推荐答案
Class not found: javac1.8
已知此错误发生在低于 1.9.0 的 Apache Ant 版本 - 与 Java 8 不兼容.如果您使用的是 Ant <1.9.0,您应该更新到 1.9.x 版本.
This error is known to happen with Apache Ant versions less than 1.9.0 - which aren't compatible with Java 8. If you're using a version of Ant < 1.9.0, you should update to a 1.9.x release.
这是相关的错误报告:https://issues.apache.org/bugzilla/show_bug.cgi?id=53347
顺便说一句,如果您只想使用 Java 8 进行编译,但不需要编译任何实际的 Java 8 语法,那么您可以将以下参数作为 解决方法 传递给 javac,这将允许您继续使用旧版本的 Ant:
Btw, if you just want to compile with Java 8, but don't need to compile any actual Java 8 syntax, then you can pass the following argument to javac as a workaround, which would allow you to continue using an older version of Ant:
-Dbuild.compiler=javac1.7
这篇关于未找到 javac1.8 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!