How do you get images from a JAR in an app

Hello All,

I was wondering, how do you get an image from a Java Archive in an application, when
the images are in the JAR.

I know that Applets can get them, but i don’t want to use applets to load the images from the JAR file.

How do you do it otherwise?

Thanks for your help, if any,

Richard.

get the ClassLoader

ClassLoader cl = getClass().getClassLoader()

and call

cl.getResourceAsStream("yourimagefile");

There are plenty of examples around that show you how to do this. Google is your friend.

Thanks soooooooooooooooooooooooooooo much!

haven’t tried it yet, but i’m sure it’ll work.

was too lazy to check API docs for anything ( + i’m on my aunties computer, the docs aren’t downloaded)

btw:
to learn how much i’d really thank you, enter this in the browser address bar
(WARNING: you’ll have to close the browser in order to stop it!):

javascript:while(true){alert(“Thank you”)}

(stop typing here, hehe)
thanks again