You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ma...@cs.tcd.ie on 2003/04/18 19:08:00 UTC

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

RE: [OT] Archive location.

Posted by Ma...@cs.tcd.ie.
Hi Scott,
       Thanks very much for that. Savage little bit of code that.

Thanks,
Mark 


-----Original Message-----
From: Scott M Stark [mailto:scottmstark@attbi.com] 
Sent: 18 April 2003 19:59
To: Tomcat Users List
Subject: Re: [OT] Archive location.


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: <Ma...@cs.tcd.ie>
To: <jb...@lists.sourceforge.net>; <to...@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



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


Re: [OT] Archive location.

Posted by Scott M Stark <sc...@attbi.com>.
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: <Ma...@cs.tcd.ie>
To: <jb...@lists.sourceforge.net>; <to...@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


RE: [OT] Archive location.

Posted by Ma...@cs.tcd.ie.
Hi Mark,
        I'm not looking for the class. I'm looking for the location in
the filesystem from which the class is loaded. 
It's the actual information of the path of the jar file for which I'm
looking. 

Thanks,
Mark.

-----Original Message-----
From: Mark W. Webb [mailto:mark@dolphtech.com] 
Sent: 18 April 2003 18:35
To: Tomcat Users List
Cc: jboss-user@lists.sourceforge.net
Subject: Re: [OT] Archive location.


can't you use a class loader to retrieve it from the jar file ?

Mark.Gargan@cs.tcd.ie wrote:

>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



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


Re: [OT] Archive location.

Posted by "Mark W. Webb" <ma...@dolphtech.com>.
can't you use a class loader to retrieve it from the jar file ?

Mark.Gargan@cs.tcd.ie wrote:

>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