This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes help needed in ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "help needed in ant" Watch "help needed in ant" New topic

help needed in ant

Thomas Greene
Ranch Hand

Joined: Aug 09, 2004
Posts: 127
I am trying to use ant to be able to compile java files.
Installed ant in d:\ant
set ant_home and path.

Copied my source files to d:\ant\src (it contains packages)

Made build.xml file in ant folder

<?xml version="1.0" encoding="UTF-8"?>

<project name="M" default="release" basedir=".">
<description>simple example build file

<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="release" location="release"/>

<target name="init">
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>

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

<target name="release" depends="compile"
description="generate the release" >
<!-- Create the release directory -->
<mkdir dir="${release}/lib"/>

<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${release}/lib/M.jar" basedir="${build}">
<attribute name="Implementation-Title" value="com.p1.p2.main"/>
<attribute name="Implementation-Vendor" value="Me Inc."/>
<attribute name="Implementation-Version" value="1.0"/>
<attribute name="Main-Class" value="com.p1.p2.main.App"/>

<target name="clean"
description="clean up" >
<!-- Delete the ${build} and ${release} directory trees -->
<delete dir="${build}"/>
<delete dir="${release}"/>

wrote ant on prompt
got the following error message

Buildfile: build.xml does not exist!
Build failed
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

I presume you are running ant from the directory your build.xml is in?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
You can also use the "-buildfile [path to the build script]" argument if you don't want to run Ant from where your build.xml is located.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
subject: help needed in ant
It's not a secret anymore!