Advertisment

Roll your Java Apps with Apache Ant

author-image
CIOL Bureau
Updated On
New Update

A software developer is always interested in concentrating more on business logic rather than spending time on configuring and deploying applications on different platforms. J2EE applications have become smarter, so have their deployment procedures. Gone are those days when you had to write different build files for different platforms. Thanks to build tools such as Ant now application deployment can be handled easily in a platform-independent way, so that you can concentrate more on business logic. This article introduces you to the powerful yet, simple XML-based scripting tool that can automate the process of compilation, deployment and configuration of your applications. We will first compare Ant with other build tools, and then, guide you through the process of compilation and deployment using Ant.

Advertisment

What is Ant?

Ant, from the Jakarta Apache Project, is a platform independent Java-based build tool. Ant started off as an internal component of Tomcat, the servlet container that is used in the reference implementation for the Java Servlet and JSP (Java Server Pages) technology. With Ant (which stands for Another Neat Tool), you can write a single build file that operates consistently on any Java platform. Ant is an XML-based scripting tool. The Ant build file must be a well-formed XML document. Soon after its release, the usefulness of Ant was recognized and its usage spread throughout the other Jakarta subprojects. It was finally made into a Jakarta subproject of its own, with the first independent release being made in July of 2000. Since then, Ant has grown and become the de facto standard for building open-source Java projects.

Why Use Ant?

Advertisment

Build tools have been around for years and they are used to transform source code and other input files into an executable form, thus, automating the build process of applications. But, these tools are usually tied very closely to the underlying operating system. Traditional projects in C or C++ often use the 'make tool' for this purpose.

While most build tools are capable of building Java applications, they do not provide OS independence, nor do they closely integrate with Java. Ant follows the WORA (Write Once Run Anywhere) approach wherein you write the build script once and it is capable of running on any OS. The conventional procedure for application deployment will involve development of small scripts in platform-specific languages. For example, on an NT machine the developer would first create a batch file that performs the compilation tasks and then runs the deployment. And, when you switch on to some other OS (say, Linux) then you have to rewrite the scripts. The real benefit of Ant is that it's platform independent, therefore, freeing the developer from the toiling efforts of creating different scripts for different OSs. This, in turn, helps in quick migration. Secondly, Ant is extensible; you can extend it to define your own custom tasks. Ant is implemented in the Java language and it can be easily integrated with your favorite IDE. Finally, Ant scores over jmk (make in Java), another Java-based build tool by not depending on external programs for development and file management.

Read about:

Advertisment

Ant Development Environment

Compiling and deploying using Ant

Running Ant

tech-news