tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <christopher.d.schu...@comcast.net>
Subject Re: PROPERTIES files cannot be found?
Date Fri, 21 Nov 2003 03:12:14 GMT
Ralf,
> I have a properties file in my jar and put in under
> Tomcat/webapps/opencms/WEB-INF/lib/mystuff.jar
> Inside the jar the properties file is under /res/myconfig.properties.
> OpenCms is a servlet in tomcat, depoyed and working. I think this question is
> generally enough to be allowed to ask here in this forum.
> 
> In my code I try to access the java property file with the following code:
> 
> 
> Properties p = new Properties();

You don't want to use a Properties object; you want to use a 
ResourceBundle. Using a FileInputStream won't work because it's in a JAR 
file, but the ResourceBundle looks in the classpath for the resource:

ResourceBundle bundle = ResourceBundle.getBundle("res/myconfig");

That should load your properties file from the JAR file.

-chris


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message