Saturday, November 21, 2009

Installing Apache Ant

Introduction
Apache Ant is a software tool for automating software build processes. It is similar to make but is implemented using the java language, requires the Java platform, and is best suited to building Java projects.
The most immediately noticeable difference between Ant and Make is that Ant uses XML to describe the build process and its dependencies, whereas Make has its Makefile format. By default the XML file is named build.xml. For a example if your project consists of many java classes and you want to build them (make .class files) in to seperate destinations you can easily do that by configuring build.xml file.
Ant is an Apache project. It is open source software, and is released under the Apache Software License.

Download


Apache Ant 1.7.1 is now available for download (This is in zip format and the binary distribution).


Installing Ant

  1. Before installing Ant make sure you have JDK1.3 or above installed on your machine and you can call javac or java -version from your command prompt.
  2. Unzip the downloaded Ant to a directory as you want. Though there are several folders in Ant Home you only need the bin and lib directories to run Ant.
  3. Now you have to set your environment variables of your machine. Those who have done this for java knows how to do it.
  • First right click on your mycomputer icon. go to advance system settings and click on the environment variable button in the advance tab of that window. Then Environment variable box will apear and under user variables select path and click edit.

  • If you have already set path for java you should see that path also under the value. Enter Your new path to the corner of your java path as below.
value C:\Program Files\Java\jdk1.6.0_05\bin;C:\apache-ant-1.7.1-bin\apache-ant-1.7.1\bin
~make sure to go deeper in to the bin of ant as in java

  • Then click ok button and you have to set new tow variables in addition to that.
  1. JAVA_HOME - click on the new button of user variables and type JAVA_HOME as variable name. For the value give C:\Program Files\Java\jdk1.6.0_05 (*not bin included) and click ok.
  2. ANT_HOME - click on the new button of user variables and type ANT_HOME as variable name. For the value give C:\apache-ant-1.7.1-bin\apache-ant-1.7.1 (* where you put your ant folder and not up to the bin) and click ok.
Now You have successfully configured settings for Apache Ant. To test it open cmd and type ant.
If you can see a out put
Buildfile: build.xml does not exist!
Build failed

Then it has successfully installed. If you come up with an error like can not find the location of ./././tool.jar, you haven not set your 3 environment variables properly.

If you are interested in building a simple java class and how to compile it using ant's build.xml file use this link.

Good Luck...!!!

No comments: