Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Images in a Jar File

 
wasif akbar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using Forte for development. In my gui I use getImage("com/teoco/EitParser/eplogo.gif") to load the image in my title bar rather than the Java logo. This works.
Now I create a jar of all of the class files and this logo. Then I create a cmd file that launches the gui, but the image doesn't appear in the title bar anymore. After creating the bar, the gui can't seem to find the gif. Any ideas as to why???
Thanks in advance.
 
Jahanzeb Sayal
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also have a same problem but the image is not on the on the title bar but used as splash screen. But if i provide the image in the correcct path outside the jar file it works perfectly.
What can i say is that it is due to the slow loading of images?
Anyone else with a better answer will be welcomed....
Jahanzeb Sayal
 
Swamy Vatti
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keep the jar file in the classpath and try this code

frame.setIcon(new ImageIcon(getClass().getResource("/dir1/dir2/gif.gif"))
hope this works
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic