Image Jars

F

FET

Hi all,
I have an application that has lots of classes. These are clubbed into
4 packages. These classes use images as well which are currently in a
directory. Everytime, I have to copy the images to install the
application. I would like these images to be in a jar file, maybe a
separate jar coz the use of these images is spread out across 4
packages so I cant possibly put all the images in all the 4 jars.
Please advise as I am unable to access the images from another jar
from the class that requires these images which is in a different jar.

Thank you in advance.
Regards.
 
D

dhek bhun kho

(e-mail address removed) (FET), Wed, 23 Jul 2003 20:55:26 -0700:
Hi all,
I have an application that has lots of classes. These are clubbed into
4 packages. These classes use images as well which are currently in a
directory. Everytime, I have to copy the images to install the
application.
I would like these images to be in a jar file, maybe a
separate jar coz the use of these images is spread out across 4
packages so I cant possibly put all the images in all the 4 jars.
Please advise as I am unable to access the images from another jar
from the class that requires these images which is in a different jar.

How are you trying to access the images currently? It should be no
problem, as long as all the JAR files have been specified on the
class path, you can access the images, simply by calling:

URL url = getClass().getResource("/directoryInAJar/image.gif");

<a
href="http://www.javalobby.com/threadMode_printfriendly.jsp?forum=16&thread=7992">
There are examples about this.
</a>

<a
href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#getResource(java.lang.String)">
Or consult the API documentation.
<a/>

What getClass().getResource(String) actually does is, call the class
loader to find out whether any given resource can be found in the search
path / class path of the current class loader.

Greets
Bhun.
path
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top