You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Leon Palermo <le...@zedak.com> on 2000/09/27 14:16:37 UTC

.properties files

Hello,

I use a .properties file from a jarred class file in my application.  Tomcat gives me an error that says it can not find the specified file.  Where do I place the .properties file so tomcat will find it?

Thanks in advance!

Leon

Re: .properties files

Posted by Mike <mi...@mgisoft.com>.
Instead of using ResourceBundle.getBundle(), try this loading from the
same classloader that already managed to load the class from the jar
file.  This classloader can load other things for you as well, like so:

InputStream is = getClass().getResourceAsStream("something.properties");
ResourceBundle res = new PropertyResourceBundle(is);


Note that something.properties is searched in the same package as where
this code sits in.  If you want to load from another package within that
same jar file, try:

InputStream is =
getClass().getClassLoader().getResourceAsStream("something.properties");
ResourceBundle res = new PropertyResourceBundle(is);


-Mike-


Leon Palermo wrote:
> 
> Hello,
> 
> I use a .properties file from a jarred class file in my application.
> Tomcat gives me an error that says it can not find the specified
> file.  Where do I place the .properties file so tomcat will find it?
> 
> Thanks in advance!
> 
> Leon

-- 
=Mike=