Example Ant build script for JBuilder application projects

By: Christopher Moeller

Abstract: Getting started with Ant scripts in JBuilder 7

Example Ant build script for applications

The following Ant build script will work with JBuilder 7 application projects.


1. Copy the italicized text below and paste into a text file.

2. Save or rename the file to "build.xml"

3. Place a copy of the file into your project directory

4. In JBuilder (7), use Add Files/Packages to add the build.xml to your project

5. When the build.xml appears in the project pane, right-click on it, choose Properties and then select the Ant tab for additional options.


<project name="JBProject" default="compile" basedir=".">

Example of a basic build.xml that will work with JBuilder applications.
This file should be placed in the project directory.
In JBuilder, add this file to the current project so that it appears in the Project Pane
Once the build.xml is added to the project, right-click on it, choose Properties and then select the Ant tab for more options.

<!-- Global properties for this script -->
<property name="src" location="src"/>
<property name="classes" location="classes"/>
<property name="archive" location="archive"/>

<target name="init">
<!-- Creates a time stamp -->
<!-- Create the classes directory structure -->
<mkdir dir="${classes}"/>

<target name="compile" depends="init" description="compiles all source files" >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${classes}"/>

<target name="archive" depends="compile" description="generate the archive" >
<!-- Put everything in ${classes} into a basic archive into $(archive)/lib/JBProject-${DSTAMP}.jar -->
<mkdir dir="${archive}/lib"/>
<jar jarfile="${archive}/lib/JBProject-${DSTAMP}.jar" basedir="${classes}"/>

<target name="clean" description="deletes classes and archive directories" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${classes}"/>
<delete dir="${archive}"/>


Server Response from: ETNASC02