Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 50025 invoked from network); 4 Dec 2002 22:48:11 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 4 Dec 2002 22:48:11 -0000 Received: (qmail 9412 invoked by uid 97); 4 Dec 2002 22:48:58 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@jakarta.apache.org Received: (qmail 9396 invoked by uid 97); 4 Dec 2002 22:48:57 -0000 Mailing-List: contact tomcat-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Users List" Reply-To: "Tomcat Users List" Delivered-To: mailing list tomcat-user@jakarta.apache.org Received: (qmail 9383 invoked by uid 98); 4 Dec 2002 22:48:57 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Message-ID: <1039042141.3dee865d13888@webmail.efcholdings.com> Date: Wed, 4 Dec 2002 17:49:01 -0500 From: Roberto Bouza To: Tomcat Users List Subject: Re: Loading Properties Files References: <016d01c29be6$5ea68570$01000001@Will> In-Reply-To: <016d01c29be6$5ea68570$01000001@Will> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 2.3.7-cvs X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Thats right. If you don't have a .war file, you can use the classes dir inside your WEB-INF dir, and create a new directory like "conf", the put inside all the properties files. In that way the ClassLoader looks for the files in there when you use something like this: try { Properties props = new Properties(); InputStream in = getClass().getResourceAsStream("/conf/db.properties"); props.load(in); ...... propertie1 = props.getProperty("propertie1"); C'ya Quoting Will Hartung : > > From: > > Subject: Loading Properties Files > > > > My problem is that the class cannot location my properties file. I am > > unable to > > use other suggested methods that I have noticed on this list since those > > problems > > involved Properties File within Servlets. > > > > After some testing, I determined for some reason the default directory it > > is looking > > for my properties file is the Windows System Directory (Determined this > by > > opening > > a file in the default directory, outputing something in it and searching > > for the file). > > > > Anyone have any ideas on how to solve this problem? I do not want to hard > > code the > > exact location due to obvious reasons > > The problem is that you appear to be loading a file with an absolute path, > versus the common form of load a properties file via the ClassLoader. > > Fumble about with the ClassLoader.getResourceAsStream to have it hunt down > your properties file, and then feed that stream to your Properties. > > public static yourMethod() > { > ClassLoader cl = YourClass.class.getClassLoader(); > Properties prop = new Properties(); > prop.load(cl.getResourceAsStream("yours.properties")); > } > > Then, just drop your properties at the right place in your WARs classes > area. > > Regards, > > Will Hartung > (willh@msoft.com) > > > > > -- > To unsubscribe, e-mail: > > For additional commands, e-mail: > > > -- = Roberto Bouza Fraga = =================================== Research & Development Engineer Ella Cisneros Fontanals Holdings Ph: (305)-860-0116 / Fax:(305)-860-9401 =================================== e-Mail:rbouza@efcholdings.com -- To unsubscribe, e-mail: For additional commands, e-mail: