ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Reilly" <>
Subject Re: java task question
Date Fri, 26 Jan 2007 21:54:29 GMT
On 1/26/07, Leo <> wrote:
> Hi,
>          I have recently started to use Ant on Eclipse IDE. I am trying to run a file
called HelloWorld located in the jse.core package. The build.xml is located at:
> C:\dev\eclipse\workspace32\jse-core\build.xml
> and HelloWorld.class is located at:
> C:\dev\eclipse\workspace32\jse-core\jse\core
> This is how my build.xml looks like:
> <project name="project1" default="run" basedir=".">
>     <target name="init">
>         <echo> The Java Version is ${} </echo>
>     </target>
>     <target name="compile">
>         <javac srcdir="." destdir="." includes="" />
>     </target>
>     <target name="run" depends="compile">
>         <java  classname="jse.core.HelloWorld"/>
>     </target>
> </project>
> The compilation part works fine, but when the run target is executed, I get the error
message as:
> Could not find jse.core.HelloWorld. Make sure you have it in your classpath
> I see that java task has a classpath attribute, but I am not sure how to use it. Please
> Thanks.
In your case you compile to the basedir, so the <java>
looks like this:
<java classname="jse.core.HelloWorld" classpath="."/>

Normally, one has a source directory contains
the source files and compiles to a build directory - build, or build/classes

   <target name="compile">
       <mkdir dir="build/classes"/>
       <javac srcdir="src" destdir="build/classes"
                  debug="yes"/>  <!-- need to set debug, otherwise ant
will use -g:none -->
   <target name="run" depends="compile">
       <java  classname="jse.core.HelloWorld" classpath="build/classes"/>
   <target name="clean">
    <delete dir="build"/>


> ---------------------------------
> Now that's room service! Choose from over 150,000 hotels
> in 45,000 destinations on Yahoo! Travel to find your fit.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message