Home | Login | Blog | Forum | Download | RSS Feed | Ajax | Hello-World | J2EE | BPM | EJB | FileNet | Hibernate | ORM | IBM | ILOG | Interview | FAQs |

Java | Apache | JVM | Others | BRMS | Oracle | Pega | SOA | Sun-Certification | Web-Service | websphere | XML |
 

JAVA DEVELOPER SITE - COMPLETE JAVA TUTORIALS

Apache Ant Basics


Share
 
 

Useful Java Links


       


Apache  Ant

 

Introduction:

 

            Ant is developed by Apache Foundation. Ant (originally an acronym for Another Neat Tool), is a command-line build tool,its main aim is to drive processes described in the build files as targets and extension points depend on each other.Ant provides special support for the Java programming language , but can be used for any process which can be  described in terms of targets and tasks. Ant is platform-independent; it is written purely in Java. Ant is an open source tool so that it is easy to use. Ant is particularly good at automating complicated repetitive tasks and thus is well suited for automating standardised build processes. Ant accepts instructions in the form of XML documents thus is extensible and easy to maintain ,and it  is easy to understand and implement Ant can use and compile source code from a variety of version controls and packaging of the compiled code and resources can also be done.

Ant is developed by Apache Foundation ,it is a a part of Apache Jakarta Project. There are many build tools like make(platform dependent), jam and many but Ant has overcome other tool shortcoming as it uses java classes with XML scripting that makes it portable through cross-platform behavior.  By default Ant uses build.xml as the name for a buildfile.

 

Installation:

In this section, we will learn how to install Ant into our system (Fedora 8 Os, Windows)

            The current version 1.8.2 of was released on 27-December-2010 . It is available for download at http://ant.apache.org/bindownload.cgi. Here, you have to click on the link apache-ant-1.7.1-bin.zip in the .zip archive to download the zip file.  After the download completes, unzip this file and install  the apache-ant-1.7.1 folder to the /opt directory . Therefore, path for the Ant directory will be /opt/apache-ant-1.8.2. Now, we have to set the PATH information.  Open the terminal and type  vi .bash_profile ” this will open the file here we need to set ANT_HOME and PATH environment variables. Set the path value /opt/apache-ant-1.8.2 to ANT_HOME variable and the path value  ${ANT_HOME}/bin; to PATH variable.  Just look at the bash_profile file in fedora to set up the environment variables.

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

JAVA_HOME=/usr/lib/jvm/java-1.7.0-icedtea-1.7.0.0

ANT_HOME=/root/apache-ant-1.8.1

CATALINA_HOME=/root/apache-tomcat-6.0.18

 

PATH=$PATH:$HOME/bin:${JAVA_HOME}/bin:${ANT_HOME}/bin:${CATALINA_HOME}/bin:

 

export PATH JAVA_HOME CATALINA_HOME

export CLASSPATH

unset USERNAME

 

            Now we will see how to set up the environment variables for Windows Os . After downloading our zipr archive file we will unzip and install the apache-ant-1.8.2 folder  in the root directory C:\ drive. So the path for the Ant directory is  C:\apache-ant-1.8.2 . Select the item "System" in the Control Panel of our system and click on the tab named "Advanced". We will see a button named "Environment Variables" appears, click it. Under Environment variables, we will find two user variables, viz., ANT_HOME and CLASS_PATH. Set the path value C:\apache-ant-1.8.2 to ANT_HOME variable and the path value C:\apache-ant-1.8.2\lib; to CLASS_PATH variable. Again in the System Variables, we have to set the value C:\jdk to JAVA_HOME variable and the value C:\apache-ant-1.8.2\bin; to Path variable.

Now, you have to check whether the installation process is done properly or not. To do this, open the  System  Terminal and run the command [root@linux ~]# ant If the following message 

[root@linux ~]# ant

Buildfile: build.xml does not exist!

Build failed

[root@linux ~]#

 

appears, then it indicates that your installation is successful; Ant is properly installed in your system..

 

Hello World in Ant

Each build file contains one project and one or  more targets. Targets contain task elements. Each task element of the buildfile can have an id attribute and can later be referred to by the value supplied to this. The value has to be unique.  For additional information, see the Using Apache Ant   )

Let us create a small build file. This is file is in current directory.

  <?xml version="1.0"?>

    <project name="MyFirstAntProject" default="MyTarget">

     <target name="init">

        <echo>Running target init</echo>

     </target>

     <target name="MyTarget" depends="init">

        <echo>Running target MyTarget</echo>

     </target>

  </project>

 

Now we will run this file using ant command. Output will be

 

Buildfile: build.xml

init:

     [echo] Running target init

MyTarget:

     [echo] Running target MyTarget

BUILD SUCCESSFUL

Total time: 0 seconds




Download Latest Java/J2EE eBooks, SCJP Dumps, SCWCD Dumps, Pega Tutorial, IBM WebSphere BPM tutorials and many more


If you need any urgent assistance on apache-ant-tutorial-for-beginners, kindly email your requirement to us at : info@javagenious.com or Contact-an-Expert. Our experts will try their best to solve your problem.

You can also subscribe to our newsletters on apache-ant-tutorial-for-beginners, to receive updates on apache-ant-tutorial-for-beginners,via email.Enter you email below:

Enter your email address:

Delivered by FeedBurner



Keyword Tags: apache-ant-tutorial-for-beginners tutorial,apache-ant-tutorial-for-beginners in java,Concepts of apache-ant-tutorial-for-beginners,Java,J2EE,Interview Questions,apache-ant-tutorial-for-beginners Examples


Comments:


Post Your Comment:

*

Yes, I would like to recieve email notifications on my reply.

Popular Posts:

 
Popular Downloads

SCJP 1.6 Dumps
JSP Interview Questions
Struts Interview Questions
Hibernate Interview Questions
SCWCD Dumps
SCBCD Dumps

Java/J2EE Tutorial
JMS Tutorials
seam richfaces tutorial
richfaces live demo
jquery example demo
JQuery Tutorial and Source Code
JSF Tutorial
XSL Tutorial
J2EE JMS
CORBA Applications
Java CERTIFICATION
SCJP 1.5
SCJP 1.6
SCWCD 1.5
SCBCD
Mis
Ajax autosuggest autocomplete from database
Struts forms and validation with webflow
Java Apache POI Examples
JDBC Tutorial
Oracle 9i & 10g
MYSQL Tutorial
php Tutorial
JQuery Examples
Upload Java File
JAXB Examples
PL-SQL Tutorial
Dojo AJAX
EJB Examples
Java IDE
Eclipse
NetBeans
IBM Rational Weblogic Workshop
Downloads
SCJP 1.6 Dumps
SCJP 1.5 DUMP
SCJP Material
SCWCD
Java Security
SCBCD Dumps
External Links
SUN Java
JOracle
IBM
PHP Certification
Technical Interview Questions
Amazon Interview Questions
Google Interview Questions
Microsoft Interview Questions
IBM Interview Questions
Yahoo Interview Questions
All Tutorials
php mysql tutorial
SCJP 1.5/1.6
SCWCD 1.5/1.6
Polymorphism
Thread Tutorial
Generics & Exceptions
Spring Struts Hibernate
Java Collections
MAP
SET
LIST
VECTOR
Advanced Java
Stateless Session Bean
Introduction to EJB
Stateful Session Bean
Java Design Patterns
HOME | FORUM | ABOUT | BLOGS | CONTACT-US