A sample ANT script to compile a java project and place the class files into build folder.

Java Code:
<?xml version="1.0"?>
<project name="test" default="compile" basedir=".">

    <property name="src" value="."/>
    <property name="build" value="build"/>

    <target name="init">
         <mkdir dir="${build}"/>
    </target>

    <target name="compile" depends="init">
         <!-- Compile the java code -->

         <javac srcdir="${src}" destdir="${build}"/>
    </target>
</project>