Sample Ant Build

Your first ANT build

 <!–?xml version=”1.0″?>

<project name=”Ant test project” default=”build” basedir=”.”>

<target name=”build” >

<javac srcdir=”src” destdir=”build/src” debug=”true” includes=”**/*.java“/>



First line of the build.xml file represents the document type declaration

Second line is comment entry.

Third line is the project tag. Each buildfile contains one project tag and all the instruction are written in the project tag.

The project tag:

<project name=”Ant test project” default=”build” basedir=”.”>  requires three attributes namely name, default and basedir.

Here is the description of the attributes:

Attribute             Description

name                    Represents the name of the project.

default                  Name of the default target to use when no target is supplied.

basedir                  Name of the base directory from which all path calculations are done.

All the attributes are required.

One project may contain one or more targets. In this example there is only one target.

<target name=”build” >

<javac srcdir=”src” destdir=”build/src” debug=”true” includes=”**/*.java”/>


Which uses task javac to compile the java files.

Here is the code of our file which is to be compiled by the Ant utility.

class AntTestExample{

public static void main (String args[]){

System.out.println(“This is Ant Test Example “);



Run the ANT file with ant command.

Above mentioned process compiles the file and places in the buildsrc directory.

Refer to examples

Java™ Application Development on Linux® – Free 599 Page eBook

Enterprise Java Virtualization:

Understanding the TCO Implications

InfoWorld’s Java IDE Comparison Strategy Guide:

Java Essential Training

Apache Jakarta Commons: Reusable Java™ Components

Enabling Rapid ROI: With Java™ – Based Business Intelligence Applications:

Single Sign-On for Java and Web Applications

Bulletproof Java Code: A Practical Strategy for Developing Functional, Reliable, and Secure Java Code

Transforming a Generic Java IDE to Your Application Specific IDE:

The Java Virtual Appliance—No OS Required

BEA WebLogic® Operations Control: Application Virtualization for Enterprise Java

Enabling Rapid ROI: With Java™ – Based Business Intelligence Applications:


Any Suggestions?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s