• Post Reply Bookmark Topic Watch Topic
  • New Topic

Image In Executable JAR  RSS feed

 
Will Paul
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created an SWT application and made it a JAR executable. However, any image files that it uses cannot be accessed within the JAR when I execute it.
I coded it like this:
Image image1 = new Image(display,"images/myimage.bmp");
and also tried this:
Image image1 = new Image(display,"myimage.bmp");
Both ways work in Eclipse, but not as a JAR.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to Use Icons
 
Will Paul
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, but if I'm not mistaken, this is for Swing not SWT.
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because it's in a jar you can't just use the String path for the file. You have to pass that String into a getResources method of the Class class.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!