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?

Reazur Rahman
  • 151
  • 1
  • 1
  • 12

1 Answers1

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

Bone
  • 91
  • 8