Return-Path: Delivered-To: apmail-jakarta-tomcat-user-archive@apache.org Received: (qmail 23830 invoked from network); 13 Feb 2002 17:16:19 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 13 Feb 2002 17:16:19 -0000 Received: (qmail 4643 invoked by uid 97); 13 Feb 2002 17:15:59 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-user@jakarta.apache.org Received: (qmail 4625 invoked by uid 97); 13 Feb 2002 17:15:58 -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 4614 invoked from network); 13 Feb 2002 17:15:58 -0000 From: "Bryan Austad" To: "Tomcat Users List" Subject: RE: Loading property files using ClassLoader.getSystemResource() Date: Wed, 13 Feb 2002 10:23:58 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Importance: Normal In-Reply-To: <3C6AA9A4.58B6B918@distributopia.com> X-OriginalArrivalTime: 13 Feb 2002 17:16:39.0010 (UTC) FILETIME=[32A77C20:01C1B4B2] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Yes, I mean the getSystemResource is a static method. I call this static method from another static method.... static public String formFullPath( String fName ) { URL url; if (fName.charAt(0) == '/'){ System.out.println("fName is " + fName); return fName; } url = ClassLoader.getSystemResource(fName); System.out.println("url is " + url); return (url == null) ? fName : url.getFile(); } When I try using ClassLoader.getResource(fName), I get a compile error: non-static method getResource(java.lang.String) cannot be referenced from a static context How do I get around this? -----Original Message----- From: Christopher K. St. John [mailto:cks@distributopia.com] Sent: Wednesday, February 13, 2002 11:00 AM To: Tomcat Users List Subject: Re: Loading property files using ClassLoader.getSystemResource() Bryan Austad wrote: > > I use a class with static methods to load properties. getResource() does > not return a static URL, so I cannot use it within my static method. > getSystemResource() returns a static URL. > static URL? Do you mean that getSystemResource() is a static method in ClassLoader? That's true, but you're allowed to call non-static methods on other objects inside a static method. In fact, getSystemResource() just gets the system classloader with getSystemClassLoader() and calls getResource() on it. Where are you calling the static methods from? From the init() of a servlet? If so, you can get the servlet's classloader and pass it to the static method. -- Christopher St. John cks@distributopia.com DistribuTopia http://www.distributopia.com -- To unsubscribe: For additional commands: Troubles with the list: -- To unsubscribe: For additional commands: Troubles with the list: