File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Problem with Ant Build 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 "Problem with Ant Build" Watch "Problem with Ant Build" New topic

Problem with Ant Build

Ashok Kumar Babu
Ranch Hand

Joined: Jul 25, 2006
Posts: 129
Hi all,

I am having a souce folder src.
Inside src I am having a package event
Inside event I am having a java file

package event;
public class Event{}

When I compile my java files using ant. Class files are created and in the class files the package declaration seems to be

package src.event;
public class Event{}

My question- Is it a problem with the build file? I have also added the build.xml below for you reference.

<project name="hibernate-tutorial" default="compile">

<property name="basedir" value="."/>
<property name="sourcedir" value="${basedir}/src"/>
<property name="targetdir" value="${basedir}/bin"/>
<property name="librarydir" value="${basedir}/lib"/>

<path id="libraries">
<fileset dir="${librarydir}">
<include name="*.jar"/>

<target name="compile">
<javac srcdir="${sourcedir}"

Thanks All
[ July 25, 2006: Message edited by: Ashok Kumar Babu ]

Ashok<br /> <br />SCJP 91%<br />SCWCD 88%
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
First, I must say that it is not necessary that you create the basedir variable.

Ant already contains a set of built-in properties and basedir is one of them. See about it here.

Now, that you want to do, I typically do it this way, and it works.

Look how I declare the basedir property in the project tag. You are missing that, and that could be causing you trouble.

Another important issue is that the build.xml file should be in the same directory where the src, bin and lib directories are.

In other words


I hope this helps!
[ July 25, 2006: Message edited by: Edwin Dalorzo ]
Rudra Narayan Garnaik
Ranch Hand

Joined: May 05, 2006
Posts: 39
Hi am giving the link for a build file which is working fine.

Make a look over it.

Open the doc and see the build.xml written on the button of this file.

web page

Regards, Rudra Narayan
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

You're really distributing a build.xml file as a DOC? You didn't want to provide it as a txt or even an XML file? I'm not trying to be rude, but doc files are of limitted use and may contain viruses.

I agree. Here's the link:
subject: Problem with Ant Build
It's not a secret anymore!