You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ralf B <am...@gmx.de> on 2003/11/20 23:22:42 UTC
PROPERTIES files cannot be found?
Hi,
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();
try {
p.load(new FileInputStream("res/myconfig.properties"));
} catch (IOException e) {e.printStackTrace();}
but it cannot be found. The java classes in this jar file are working fine.
What is wrong here? I expect that Tomcat does include all the jar files and
start the path from the root of each jar file. It should therefore find the
resource file...
Any ideas?
Ralf
--
NEU F�R ALLE - GMX MediaCenter - f�r Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gru�, GMX FotoService
Jetzt kostenlos anmelden unter http://www.gmx.net
+++ GMX - die erste Adresse f�r Mail, Message, More! +++
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: PROPERTIES files cannot be found?
Posted by Christopher Schultz <ch...@comcast.net>.
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