You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Wa...@toyota-europe.com on 2004/04/07 14:21:11 UTC
Problem loading properties file using the CLASSPATH
Hi,
The platform I'm working on is the AIX platform.
I have a ANT listener loading a properties file located in a folder
specified inside the classpath.
This is the code I'm using:
InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream
("TheProperties.properties");
The location of the properties file is searched using the CLASSPATH.
This works fine in ANT version 1.5.4, but not anymore in ANT version 1.6.1.
Probably related to the new classloader implementation. How can I solve
this issue?
PS: I've used the ant script file from 1.5.4 for the ANT 1.6.1 which has
the org.apache.tools.ant.Main as entry point, it works fine. When I use the
new entry point org.apache.tools.ant.launch.Launcher it doesn't work
anymore.
Anybody more info on this?
Walter
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Problem loading properties file using the CLASSPATH
Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 7 Apr 2004, Walter Heestermans
<Wa...@toyota-europe.com> wrote:
> InputStream in =
> ClassLoader.getSystemClassLoader().getResourceAsStream
> ("TheProperties.properties");
>
> The location of the properties file is searched using the CLASSPATH.
>
> This works fine in ANT version 1.5.4, but not anymore in ANT version
> 1.6.1. Probably related to the new classloader implementation. How
> can I solve this issue?
Where exactly is your resource? Inside a jar that lives in
ANT_HOME/lib, I assume.
The content of ANT_HOME/lib has been on the system CLASSPATH in Ant
1.5.x but no longer is in Ant 1.6.x.
Use getClass().getClassLoader().getResourceAsStream(...)
instead, this will look up the resource in the same classloader that
has loaded your class.
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org