Recent Pos

Ant Build Tool



⇒ Ant is a tool for Java application development from Apache which is used for build and deploy of Java applications.
⇒ If we are developing web application or enterprise application, we need to follow few steps to run the application in the server as follow:
java ant build tool tutorial

  1. Develop required files(.java, .jsp, .html etc).
  2. Set the required .jar files into classpath.
  3. Generate .class files.
  4. Create required directory structure.
  5. Generate .war file.
  6. Start the server.
  7. Deploy .war file into server.
  8. Verify functionality of our application based on our project to requirement.
  9. Sometimes we need to stop server.
  10. Sometimes we need to un-deploy the application.


⇒ All the above steps are called as Build Process steps for Java application.

⇒ If we are manually follow all the above build process steps then it will increases the project development time and it is also increases the project cost.

⇒ To resolve these problems we need to use any one of build tool.

⇒ If we are using any of the build tool in our application to automate build process steps then it will decreases project development time and project development cost.

⇒ Now we have build tools in the market to automate build process steps for the Java applications, most popular is 1. Ant and 2. Maven


⇒ Ant is a build tool, by using this tool we can automate build process steps for Java applications.

⇒ It is an open source framework which is given by Apache Software Foundation.

⇒ Ant build tool developed by using Java language.

Environment setup for the ANT:

1. Download ANT software (ant…zip file) from Apache website.

2. Extract the zip, and set two system environment variables for example:

Computer->Properties->Advanced system settings->Environment variables->System variable

ANT_HOME=E:apache-ant-1.8.4  [create a new system variable]

PATH=E:apache-ant-1.8.4bin  [ edit the “path” system variable and add it by appending ‘;’ into the existing content]

3. To verify whether ANT successfully installed or not, we need to open command prompt and enter below command:

C:\Users\technowlogeek>ant -version


⇒ If we want automate build process steps by using ANT build tool then we need to provide some instructions about our build process steps in the form of XML tags to the ANT build tool and that XML file name should be “build.xml” file and we need to save the “build.xml” file in the project root directory.

⇒ To run build.xml file we need to open command prompt and go to where our build.xml file existed.

⇒ Now to run build.xml file we have 2 ways:

  1. Executing target by target – To execute target by target we change directory in Command Prompt and execute below command:
    C:Userstechnowlogeek>cd E:helloworld  [Here “E:helloworld” is my project workspace, we can create it anywhere we want.]

    Syntax: E:helloworldant <target name>

    Example: E:helloworldant compile

  2. Executing default target – If we want to execute default target we need to use “default” attribute in <target> tag and we need to use “depends” attribute in all the target tags in “build.xml” file.


⇒ The project directory structure should be as below:

ant project directory structure

Next: ->Ant build.xml and properties file

1 Comment
  • samir

    September 13, 2016 at 2:24 pm Reply

    good tutorial

Post a Comment