Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

image out of a jar file

  Asked By: Matilda    Date: Jul 02    Category: Java    Views: 771
  

I'm starting to play around with Java
Web Start. I was wondering if someone could post a
simple example of how to get an image (newfile.gif) out
of a jar file so that it can be used to create a
JButton.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Muriel Dunn     Answered On: Jul 02

I pulled this directly from the "How to Use
Icons" portion of the Swing tutorial:<br><br>ImageIcon
icon = null;<br>URL iconURL =
ClassLoader.getSystemResource("images/middle.gif");<br>if (iconURL != null)
{<br> icon = new
ImageIcon(iconURL, "an icon");<br>}<br><br>This should work because
any JARs loaded through Java Web Start should be part
of the classpath (as far as I understand
it).

 
Answer #2    Answered By: Rochelle Elliott     Answered On: Jul 02

If you want to use the newfile.gif out of the jar
file to use else where, you can just use WinZip to
extract it.... jar  files are just fancy zip files which
winzip can extract.<br><br>Like Anthony said, since the
jar file  is in the class path when you install... if
you just want to use it from the jar file, use his
example.<br><br>Stephen McConnell<br>http://www.crosslogic.com

 
Didn't find what you were looking for? Find more on image out of a jar file Or get search suggestion and latest updates.




Tagged: