ANT projects can be run using Eclipse. Eclipse is an Integrated Development Environment, which gives workspace and provides various plug-ins to customize the environment.
To include targets using FTP and to upload files to the remote server, some additional jar files are required such as:
Commons-net-*.jar Jakarta-oro-*.jar
Step-2
Now, copy the jar file in lib folder in Eclipse. The folder will be as follows:
C:\Program Files\Eclipse\plugins\org.apache.ant_1.9.4\lib
Step-3
Then, go to
Window -> Preferences -> Ant -> Classpath -> Ant Home Entries -> Add External JAR’s -> select the two jar files in Lib folder.
Step-4
Integrating with eclipse can be done as follows.
Create a project as AntExample. Right click on the project and
New -> Other -> XML -> Enter build.xml -> FinishBuild the structure as shown below.
Now build.xml will be as follows
[java]
<?xml version="1.0" ?>
<project name="Ant Example" default="execute">
<target name="init" depends="clean">
<mkdir dir="build/classes" />
</target>
<target name="compile" depends="init">
<javac srcdir="src" destdir="build/classes" />
</target>
<target name="execute" depends="compile">
<java classname="com.splessons.helloworld.HelloWorld" classpath="build/classes" />
</target>
<target name="clean">
<delete dir="build" />
</target>
</project>[/java]
HelloWorld.java
[java]
package com.splessons.helloworld;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
[/java]
Step-5
To build a project, right click on build.xml and click on Ant Buildas shown below.
If the build is successful, the following output will appear:
[java]
hello:
[echo] Hello World!
BUILD SUCCESSFUL
Total time: 337 milliseconds[/java]
Summary
Key Points
IDE stands for Integrated Development Environment.
External jar files are to be set in Ant Classpath.