Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Ant Eclipse IDE Integration

DZone's Guide to

Ant Eclipse IDE Integration

·
Free Resource

To integrate Ant build file with the Eclipse IDE, first create a build.xml file, right click the project select New->Other->XML, enter the name as build.xml and click Finish.

<?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.vaannila.helloworld.HelloWorld" classpath="build/classes" />
	</target>

	<target name="clean">
		<delete dir="build" />
	</target>
	
</project>

To build the project right click the build.xml file and select Ant Build.

The HelloWorld.java file will be compiled and executed. The following message shows the sequence of events that happen once the build file is executed.

<?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.vaannila.helloworld.HelloWorld" classpath="build/classes" />
	</target>

	<target name="clean">
		<delete dir="build" />
	</target>
	
</project>

You can download the build file here.

Build file : Download
Project : Download
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}