0

I am learning Java ant. I created a project in eclipse call hello world. And then i did a export on the project and created a ant build file. When i run the ant file it fails complains about: BUILD FAILED C:\Users**\workspace\HelloWorld\build.xml:31: Class not found: javac1.8

and point to this line:

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

I am using eclipse kepler.

Here is my build.xml file:

<?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>

Does anyone know why this is happening?

1 Answer 1

0

Is your version of Ant less than 1.9.0? If so, its not compatible with java 8. You're best off updating your current version of Ant.

If you're not using any java 8 syntax, and just want to compile with it, you can pass "-Dbuild.compiler=javac1.7" to javac

3
  • How do i update my ant version because it's seem to point to eclipse plugin folder Oct 15, 2015 at 22:30
  • The answer here explains it perfectly: stackoverflow.com/questions/5206431/…
    – Bone
    Oct 19, 2015 at 13:08
  • hey i did what you asked i am still getting the same error on this line: <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}"> Oct 20, 2015 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.