You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Antonio W. Lagnada" <nf...@msn.com> on 2001/11/08 17:22:46 UTC

Re: jar files and gifs

Is this a java/java swing app or a servlet/jsp?  I am confused since this is a tomcat user mail group.

Anyways, if it is a java app, one example would be (if you are using ImageIcon or other classes that supports URL in their constructor):

URL imageURL = System.getClass().getClassLoader().getResource("MyImage.gif");  
ImageIcon imageIcon = new ImageIcon(imageURL);

If this is a JSP/Servlet question, one approach is to create some image factory that reads the image.  This image factory will then convert the image into byte streams so the web browser would be able to display it.

** Note that the above example assumes that it is located on the root of the jar file, not in a folder hierarchy somewhere.
You may need to use getResource("images/Myimage.gif").  I don't know if this works.

If you have a servlet that returns a bytestream give the gif file name, ie
http://localhost:8080/ImageService?imageName=MyImage.gif

You would be able to utilize this in html/jsp as:

<image src="http://localhost:8080/ImageService?imageName=MyImage.gif">

You will also have to load the image via the URL.openConnection(), etc...

  
----- Original Message -----
From: Adrian Caramarin
Sent: Thursday, November 08, 2001 6:09 AM
To: tomcat-user@jakarta.apache.org
Subject: jar files and gifs
  
Hello,

    I have a jar file, which contains some java .class files and two directories /images and /sounds. The problem is when I run the jar file, the images from it are not found. So, on the screen I don't see any gif.  
    Could anyone tell me how could I access the gifs files from the jar archive ?

Many thanks,
AdrianGet more from the Web.  FREE MSN Explorer download : http://explorer.msn.com

Re: jar files and gifs

Posted by Adrian Caramarin <ad...@psgl.ro>.
Hi,

    Sorry for confusing you, I was talking about an java application, not a
jsp.
 Anyway thank you very much

Sincerely,
Adrian

----- Original Message -----
From: "Antonio W. Lagnada" <nf...@msn.com>
To: "Tomcat User" <to...@jakarta.apache.org>
Sent: 08 November, 2001 06:22 PM
Subject: Re: jar files and gifs


Is this a java/java swing app or a servlet/jsp?  I am confused since this is
a tomcat user mail group.

Anyways, if it is a java app, one example would be (if you are using
ImageIcon or other classes that supports URL in their constructor):

URL imageURL =
System.getClass().getClassLoader().getResource("MyImage.gif");
ImageIcon imageIcon = new ImageIcon(imageURL);

If this is a JSP/Servlet question, one approach is to create some image
factory that reads the image.  This image factory will then convert the
image into byte streams so the web browser would be able to display it.

** Note that the above example assumes that it is located on the root of the
jar file, not in a folder hierarchy somewhere.
You may need to use getResource("images/Myimage.gif").  I don't know if this
works.

If you have a servlet that returns a bytestream give the gif file name, ie
http://localhost:8080/ImageService?imageName=MyImage.gif

You would be able to utilize this in html/jsp as:

<image src="http://localhost:8080/ImageService?imageName=MyImage.gif">

You will also have to load the image via the URL.openConnection(), etc...


----- Original Message -----
From: Adrian Caramarin
Sent: Thursday, November 08, 2001 6:09 AM
To: tomcat-user@jakarta.apache.org
Subject: jar files and gifs

Hello,

    I have a jar file, which contains some java .class files and two
directories /images and /sounds. The problem is when I run the jar file, the
images from it are not found. So, on the screen I don't see any gif.
    Could anyone tell me how could I access the gifs files from the jar
archive ?

Many thanks,
AdrianGet more from the Web.  FREE MSN Explorer download :
http://explorer.msn.com



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>