2015-10-15 39 views
0

我正在学习Java ant。我在eclipse call hello world中创建了一个项目。然后我做了一个项目导出并创建了一个ant构建文件。当运行失败的蚂蚁文件抱怨:BUILD FAILED C:\用户** \工作空间\的HelloWorld \ build.xml中:31:没有发现类别:javac1.8因为没有找到类,Java ant build失败

并指向这一行:

<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}"> 

我正在使用eclipse kepler。

这里是我的build.xml文件:

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<!-- WARNING: Eclipse auto-generated file. 
       Any modifications will be overwritten. 
       To include a user specific buildfile here, simply create one in the same 
       directory with the processing instruction <?eclipse.ant.import?> 
       as the first entry and export the buildfile again. --> 
<project basedir="." default="build" name="HelloWorld"> 
    <property environment="env"/> 
    <property name="debuglevel" value="source,lines,vars"/> 
    <property name="target" value="1.2"/> 
    <property name="source" value="1.3"/> 
    <path id="HelloWorld.classpath"> 
     <pathelement location="bin"/> 
    </path> 
    <target name="init"> 
     <mkdir dir="bin"/> 
     <copy includeemptydirs="false" todir="bin"> 
      <fileset dir="src"> 
       <exclude name="**/*.java"/> 
      </fileset> 
     </copy> 
    </target> 
    <target name="clean"> 
     <delete dir="bin"/> 
    </target> 
    <target depends="clean" name="cleanall"/> 
    <target depends="build-subprojects,build-project" name="build"/> 
    <target name="build-subprojects"/> 
    <target depends="init" name="build-project"> 
     <echo message="${ant.project.name}: ${ant.file}"/> 
     <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}"> 
      <src path="src"/> 
      <classpath refid="HelloWorld.classpath"/> 
     </javac> 
    </target> 
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/> 
    <target name="HelloWorld"> 
     <java classname="HelloWorld" failonerror="true" fork="yes"> 
      <classpath refid="HelloWorld.classpath"/> 
     </java> 
    </target> 
</project> 

有谁知道为什么发生这种情况?

回答

0

您的Ant版本是否低于1.9.0? 如果是这样,它与java不兼容8. 您最好更新当前版本的Ant。

如果你不使用任何Java 8语法,只是想用它来编译,你可以通过“-Dbuild.compiler = javac1.7”到javac的

+0

如何更新我的蚂蚁的版本,因为它是似乎指向日食插件文件夹 –

+0

这里的答案完美解释:http://stackoverflow.com/questions/5206431/how-to-upgrade-the-ant-built-into-eclipse – Bone

+0

嘿,我做了你问我在这一行仍然会出现相同的错误:'' –

相关问题