tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Barclay <Daniel.Barc...@digitalfocus.com>
Subject Re: jar-files
Date Tue, 17 Oct 2000 16:07:34 GMT
Björn Stiegler wrote:
> 
> Hi
> 
> i have some problems with a jar file. I want to load my jar file from a
> servlet with the following code:
> 
> line xxx  String pathToServlet =
> ( this.getClass().getResource( "my.jar" ).getFile() ).substring( 1 );
> line yyy File jarServlet = new File( pathToServlet );

What exactly are you trying to do?

What do you mean by "I want to load my jar file"?  That doesn't make
sense unless you're really going to process the internal structure of 
the Jar file yourself.  

Do you mean you want to load something that is stored in your Jar file?  
If so, make sure the Jar file is on your class path or somewhere that
the system will look for Jar files (such as a libs directory in a
Web Application or WAR file, for Tomcat), and pass getResource the
name of the resource you want to load.  

(Also, don't try to get a filename from the resource name and then
operate from that filename; the resource might not have a filename, e.g., 
if it's inside a Jar file.   Use getResourceAsStream, etc., to read
the resource.)

Or do you mean that the Jar file is not on the class path or anywhere
that the system checks, and you want to use it without adding to the class 
path?  That would probably require a subclass of ClassLoader (to indicate 
where to find the Jar file).


Daniel
-- 
Daniel Barclay
Digital Focus
Daniel.Barclay@digitalfocus.com

Mime
View raw message