You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Cornelissen, Frans [JanBe]" <FC...@janbe.jnj.com> on 2000/09/05 09:11:11 UTC

A problem with my Ant build file (Task "java")

Hello,

I have this problem with Ant:

when I use my build.xml, my files get compiled and
are placed in the right directory, but the target "run" doesn't work.

In this target, the built in task "java" is used. Could it be that
there's something wrong with this task?

<target name="init">
  <property name="src" value="src" />
  <property name="build" value="build" />
  <property name="class_path" value="build" />
 </target>

...

<target name="run" depends="compile">
  <java classname="Test" classpath="${class_path}" args="test 1 2"/>
 </target>



The directory structure is:

..
|
----- testAnt
           |
           ---------- build (created by build.xml - will contain all the
class file)
           ---------- src
           ---------- build.xml

The basedir is "testAnt", the properties "build" and "class_path" are set to
"build".
No packages are used in the source files.
When I type "java -cp build Test" on the command line, no problems arise and
my program is 
shown.

What am I doing wrong?

Kind regards,

JAN SMETS

--
 Best regards,
 vriendelijke groeten,

 Frans Cornelissen  tel 32-14-60-3327
 Janssen Research Foundation fax 32-14-605788
 Turnhoutseweg 30  e-mail fcorneli@janbe.jnj.com
 B2340 Beerse, Belgium


Re: A problem with my Ant build file (Task "java")

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "j" == jeroen  <15...@student.eur.nl> writes:

 j> note: the documentation says fork="yes" but I believe "true" works
 j> also.

as well as "on". It's a matter of taste.

Stefan

Re: A problem with my Ant build file (Task "java")

Posted by jeroen <15...@student.eur.nl>.
Does it work when you fork the execution with fork="true"? Like this:

<java classname="Test" classpath="${class_path}" args="test 1 2"/
fork="true">

note: the documentation says fork="yes" but I believe "true" works also.

jeroen

----- Original Message -----
From: "Cornelissen, Frans [JanBe]" <FC...@janbe.jnj.com>
To: <an...@jakarta.apache.org>
Sent: Tuesday, September 05, 2000 9:11 AM
Subject: A problem with my Ant build file (Task "java")


> Hello,
>
> I have this problem with Ant:
>
> when I use my build.xml, my files get compiled and
> are placed in the right directory, but the target "run" doesn't work.
>
> In this target, the built in task "java" is used. Could it be that
> there's something wrong with this task?
>
> <target name="init">
>   <property name="src" value="src" />
>   <property name="build" value="build" />
>   <property name="class_path" value="build" />
>  </target>
>
> ...
>
> <target name="run" depends="compile">
>   <java classname="Test" classpath="${class_path}" args="test 1 2"/>
>  </target>
>
>
>
> The directory structure is:
>
> ..
> |
> ----- testAnt
>            |
>            ---------- build (created by build.xml - will contain all the
> class file)
>            ---------- src
>            ---------- build.xml
>
> The basedir is "testAnt", the properties "build" and "class_path" are set
to
> "build".
> No packages are used in the source files.
> When I type "java -cp build Test" on the command line, no problems arise
and
> my program is
> shown.
>
> What am I doing wrong?
>
> Kind regards,
>
> JAN SMETS
>
> --
>  Best regards,
>  vriendelijke groeten,
>
>  Frans Cornelissen  tel 32-14-60-3327
>  Janssen Research Foundation fax 32-14-605788
>  Turnhoutseweg 30  e-mail fcorneli@janbe.jnj.com
>  B2340 Beerse, Belgium
>


Re: A problem with my Ant build file (Task "java")

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "CF" == Cornelissen, Frans <fc...@janbe.jnj.com> writes:

 CF> when I use my build.xml, my files get compiled and are placed in
 CF> the right directory, but the target "run" doesn't work.

 CF> <java classname="Test" classpath="${class_path}" args="test 1 2"/>

You don't say what exactly happens (and what doesn't work). My guess
is that the <java> task doesn't use the classpath you've provided. 

In Ant 1.1 you will need to specify fork="yes" and run the <java> task
in a different VM to make it use your classpath (a warning should have
been generated BTW). Current CVS will use your classpath even in the
same VM by means of a separate class loader.

Stefan