tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott M Stark" <scottmst...@attbi.com>
Subject Re: [OT] Archive location.
Date Fri, 18 Apr 2003 18:59:23 GMT
Tests 637>cat tstFindClass.java
import java.net.URL;
import java.util.Enumeration;

class tstFindClass
{
   public static void main(String[] args) throws Exception
   {
      ClassLoader loader = Thread.currentThread().getContextClassLoader();
      Enumeration urls = loader.getResources("java/lang/String.class");
      while( urls.hasMoreElements() )
      {
         URL url = (URL) urls.nextElement();
         System.out.println(url);
      }
   }
}
Tests 638>java tstFindClass
jar:file:/C:/usr/local/Java/jdk1.3.1_06/jre/lib/rt.jar!/java/lang/String.class

xxxxxxxxxxxxxxxxxxxxxxxx
Scott Stark
Chief Technology Officer
JBoss Group, LLC
xxxxxxxxxxxxxxxxxxxxxxxx

----- Original Message ----- 
From: <Mark.Gargan@cs.tcd.ie>
To: <jboss-user@lists.sourceforge.net>; <tomcat-user@jakarta.apache.org>
Sent: Friday, April 18, 2003 10:08 AM
Subject: [OT] Archive location.


> Hi folks,
>            This is slightly off topic in that it's indirectly related to
> my problem. I have a version of a class file that's located in a jar
> file somewhere in the classpath of my build. From code I need to be able
> to retrieve the location of this jar file in my filesystem most likely
> by using the Classloader.
>  
>  
> e.g. if I was looking for the jar file containing the java.lang.String
> class then the code would return the path
> 'c:\j2sdk1.4.1_01\jre\lib\rt.jar'.
>  
> Is this possible? I saw it on an Eclipse post before but I can't
> retrieve it...
>  
> Thanks,
> Mark.
>  
> 

---------------------------------------------------------------------
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