ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <co...@cortexebusiness.com.au>
Subject Re: problems loading resources within classpath
Date Mon, 30 Jul 2001 13:59:37 GMT
Dave,

What exactly were you expecting when you call getSystemResourceAsStream as
opposed to getResourceAsStream? By using the System classloader, you are
effectively bypassing the classloader created to load and execute your Java
task.

----- Original Message -----
From: "dave young" <dyoung@bsis.com.au>
To: <ant-user@jakarta.apache.org>
Sent: Monday, July 30, 2001 6:56 PM
Subject: Re: problems loading resources within classpath


> After a couple more tests, it seems that as long as the directory
> containing the file is in the CLASSPATH when ant is started, that the
> resource will be found.
>
> Another test has shown that if I set fork="yes" in the <java> task, that
> the class loader seems to behave itself a bit better.
>

Entirely expected since these two actions both result in the property being
available to the System classloader in operation when your class is
executing.

> >
> > does ant do bizarre things to the class loading that would affect this
> > sort of behaviour?

No it is not bizarre. Ant does do some bizarre classloader tricks when
running <java> tasks to make those tasks behave the same way as they do
when run from the command line, but in the end your class does run in the
same VM and it needs to cooperate, especially with shared resources such as
the System class loader.

> > we find that loading resources from the class path is
> > especially useful, since we run on both windoze and slowlaris
platforms,
> > so not hardcoding directory paths is definitely a good thing for us.
> >

just use getResourceAsStream and you should be fine.

> > hope somebody can help us out.
> >
> > best regards,
> >
> > dave young.
>

Conor




Mime
View raw message