Images out of a jar

S

Sam Takoy

Hi,

Can someone point to a source where it is explained how to add image
files to a jar and then use them in an applet. I'm not able to find the
info regarding where to put the image within the jar and then how to
extract it later.

Many thanks in advance,

Sam
 
A

Arne Vajhøj

Can someone point to a source where it is explained how to add image
files to a jar and then use them in an applet. I'm not able to find the
info regarding where to put the image within the jar and then how to
extract it later.

They can be anywhere but maybe something like:
images/foobar.jpg
would be logical.

new ImageIcon(getClass().getResource("images/foobar.jpg"))

should get the image in a form that be used by Swing controls.

Arne
 
J

John B. Matthews

Sam Takoy said:
Can someone point to a source where it is explained how to add image
files to a jar and then use them in an applet. I'm not able to find
the info regarding where to put the image within the jar and then how
to extract it later.

As Arne's suggests, getResource() is a convenient approach. Although
this example is an application rather than an applet, you might have a
look here:

<http://sites.google.com/site/drjohnbmatthews/googleolympiad>
 
R

Roedy Green

Can someone point to a source where it is explained how to add image
files to a jar and then use them in an applet. I'm not able to find the
info regarding where to put the image within the jar and then how to
extract it later.

see http://mindprod.com/jgloss/image.html
http://mindprod.com/jgloss/resource.html
http://mindprod.com/jgloss/ant.html
http://mindprod.com/jgloss/jarexe.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
To err is human, but to really foul things up requires a computer.
~ Farmer's Almanac
It is breathtaking how a misplaced comma in a computer program can
shred megabytes of data in seconds.
 

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,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top