Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: 10 Minutes Guide to Ant

10 Minutes Guide to Ant 10 Minutes Guide to Ant Previous Tutorial Index Next Introduction Well for the next 10 minutes get ready to devote to the ant guide. This will make some sence to the ant. Ant is a free tool under GNU Licence and is

Tutorial Details:

freely available at http://jakarta.apache.org/ant/ , current version of ant is 1.4.1. Ant allows the developer to automate the repeated process involved in the development of J2EE application. Developers can easily write the script to automate the build process like compilation, archiving and deployment.
For this tutorial I am using 1.4.1 and jdk1.4. I am also using Jboss 3.0 (with tomcat) downloaded from http://www.apache.org to deploy and test J2EE application developed in this lesson. In order to understand this tutorial you should have a solid knowledge of java programming and development of web application using java technologies.
Lesson 1
Downloading and Installing Ant
Before installing Ant make sure you have JDK1.3 or above installed on your machine.
For this tutorial download ant from http://jakarta.apache.org/ant/ and unzip the file into your favorite directory.
Set the class path to the bin directory of the ant.
Let's assume that Ant is installed in c:\ant\ . The following code has to be put into autoexec.bat file:
set ANT_HOME=c:\ant
set JAVA_HOME=c:\jdk1.3
set PATH=%PATH%;%ANT_HOME%\bin
Testing Ant
Go to command prompt and issue the following command.
C:\anttest>Ant
Buildfile: build.xml does not exist!Build failed
C:\anttest>
If every this is installed correctly Ant will give the above message.
Now its time to do some work with Ant.
Ant uses configuration file called build.xml to work. This is the file where you defines the process of compiling, building and deploying.
Writing build.xml file
build.xml is a xml file used by ant utility to compile, build and deploy or run the application.
Now here is code of simple build.xml file which compiles a java file present in src directory and places compiled class file in build/src directory.




includes="**/*.java"
/>


First line of the build.xml file represents the document type declaration. Next 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:

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.

includes="**/*.java"
/>

Which uses task javac to compile the java files.
Here is the code of our test1.java file which is to be compiled by the Ant utility.
class test1{
public static void main (String args[]){
System.out.println("This is example 1");
}
}
Download the code of this tutorial and unzip it in c:\. files will be unzipped in anttest directory. To run the Ant utility to compile the file go to c:\anttest\example1 and issue ant command. You will receive the following out put.
C:\anttest\example1>ant
Buildfile: build.xml
build:
[javac] Compiling 1 source file to C:\anttest\example1\build\src
BUILD SUCCESSFUL
Total time: 4 seconds
C:\anttest\example1>
Above mentioned process compiles the file and places in the build\src directory.
In the next lesson I will show you how to use ant to compile, build and deploy your web application to the Jboss 3.0
Previous Tutorial Index Next


 

Rate Tutorial:
http://www.roseindia.net/jboss/10_minutes_guide_to_ant.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
10 Minutes Guide to Ant

View Tutorial:
10 Minutes Guide to Ant

Related Tutorials:

JavaWorld Developer Tools Guide: IDE
JavaWorld Developer Tools Guide: IDE
 
JavaWorld Developer Tools Guide: Testing Tools
JavaWorld Developer Tools Guide: Testing Tools
 
JavaWorld Developer Tools Guide: Compiler, Code Management
JavaWorld Developer Tools Guide: Compiler, Code Management
 
JavaWorld Developer Tools Guide
JavaWorld Developer Tools Guide
 
JavaWorld Developer Tools Guide: Virtual Machine
JavaWorld Developer Tools Guide: Virtual Machine
 
Automate your build process using Java and Ant - JavaWorld October 2000
Automate your build process using Java and Ant - JavaWorld October 2000
 
Java tools reign supreme - JavaWorld celebrates the leading Java tools
Java tools reign supreme - JavaWorld celebrates the leading Java tools
 
Top 15 Ant Best Practices
Top 15 Ant Best Practices Ant, building and deploying Java applications required a hodgepodge of platform-specific scripts, makefiles, proprietary IDEs, or manual processes. Now, nearly every open source Java project uses Ant. A great number of companie
 
Writing Ant Tasks
Writing Ant Tasks A nice feature of Ant is that it is designed to allow you to add your own tasks and use them in an build. This article shows you the basics of writing an Ant task and how to get a task to work.
 
Beginner Guide to Linux Server
Beginner Guide to Linux Server Beginner Guide to Linux Server Introduction Linux is know for its security, performance, reliability. Many business units are looking towards Linux as it provides low costs software for them. Earlier Linux used to
 
Domain Registration Guide
Domain Registration Guide Domain Name Registrations Domain Name Registration Guide This guide is a must for any one wants to register domains.
 
10 Minutes Guide to Ant
10 Minutes Guide to Ant 10 Minutes Guide to Ant Previous Tutorial Index Next Introduction Well for the next 10 minutes get ready to devote to the ant guide. This will make some sence to the ant. Ant is a free tool under GNU Licence and is
 
Welcome to the Jboss 3.0 Tutorial
Welcome to the Jboss 3.0 Tutorial Welcome to the Jboss 3.0 Tutorial 10 Minutes Guide to Ant Comprehensive description of Ant with example. Building Web Application With Ant and Deploying on Jboss 3.0 This lesson shows you how to build you web
 
Beginner Guide to Linux Server
Beginner Guide to Linux Server Beginner Guide to Linux Server Introduction Linux is know for its security, performance, reliability. Many business units are looking towards Linux as it provides low costs software for them. Earlier Linux used to
 
Roseindia.net Place to Get Cheap Linux cds in India!!
Roseindia.net Place to Get Cheap Linux cds in India!! Cheapest latest Linux CDs in India. Free Linux: Linux is free and it can be downloaded from the Internet at free of cost. But it requires a lot of time to download and check the ISO image and
 
The Beginners Linux Guide
The Beginners Linux Guide The Beginner's Guide to Linux Dedicated website to Linux containing Online Resource, Links to Linux Resources and Tutorials. Here you will find a lot of tutorials and information about the Linux. What is Linux? This
 
Beginner to advance guide to the Apache Struts
Beginner to advance guide to the Apache Struts The Complete Apache Struts Tutorial This complete reference of Jakarta Struts shows you how to develop Struts applications using ant and deploy on the JBoss Application Server. Ant script is provided
 
Struts Guide
Struts Guide Struts Guide This tutorial is extensive guide to the Struts Framework. In this tutorial you will learn how to develop robust application using Jakarta Struts Framework. This tutorial assumes that the reader is familiar with the web
 

Submission Home | Submit Web Sites | Why Manual Submission? | Web Promotion Guide
 
Sun Studio 10 Documentation Online
Full documentation for the Sun Studio 10 compilers and tools is now available on the Sun Developer's Portal.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.