Here's my simple java file:
package ant;
public class HelloAnt {
public static void main(String[] args) {
System.out.println("Hello Ant!");
}
}
The main things to remember when using a package or IDE like Eclipse is to:
- include the classpath (the build directory)
- include the package name before the class name. E.g., ant.HelloAnt
Download 'Hello Ant' Eclipse Project (with Ant .xml files)
<project name="HelloAnt" default="run">
<description>
Simple Ant build file for Hello Ant
</description>
<property name="src.dir" location="src" />
<property name="build.dir" location="build" />
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="makedir">
<mkdir dir="${build.dir}" />
</target>
<target name="compile" depends="clean, makedir">
<javac srcdir="${src.dir}" destdir="${build.dir}" />
</target>
<target name="run" depends="compile">
<java classname="ant.HelloAnt" fork="true">
<classpath>
<path location="${build.dir}" />
</classpath>
</java>
</target>
</project>
No comments:
Post a Comment