Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

image is missing when jaring

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm gradually improving the complexity of my application using ant

i started with a jframe that displays an icon, then added images to tabs in a tabbedPane and now i'm trying to display a background image in a panel

though apparently quite simple this is hard: i'm trying to achieve two goals - running and jaring using the img folder in the classpath and also trying to run and jar using the jared img folder in the classpath instead (the idea is mastering these aspects in order to later being able to reference any jar i need to my application, always using ant)

so i have the needed images inside a folder called img
i jared this folder getting an imgjar.jar

in my code i use the path to my images like this (though i tried numerous combinations, mostly because no image entered when i started using packages, but that will be matter for another topic ):

now i "turn off" the imgjar out from the classpath and try to run the application using just the img folder placed in the classpath - all works perfectly

but when, with the very same setup, i jar the application, the background image doesnt show up - and i wonder why



some relevant code:


my ant file:


can someone please help me sorting this out, please?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
curiously enough:

when i "switch" the classpath - i.e. - i put the imgjar in the classpath and remove the img folder from the classpath i get the following result:
when running - the background image is the only one to enter
when i jar the application - the background image is the only one not to enter
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is this question different from this one:
http://www.coderanch.com/t/469220/Ant-Maven-Other-Build-Tools/jaring-images-folder
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter Johnson wrote:How is this question different from this one:
http://www.coderanch.com/t/469220/Ant-Maven-Other-Build-Tools/jaring-images-folder

i'm sorry but they just dont relate (well, its about the same aplication ) : in this one i've a problem with an image display, while in the other topic i'm questioning concrete jaring with ant - no problems whatsoever with displaying images, just asking how to jar a file

dont you agree?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in case someone is interested in this topic, i found a solution, using the trial and error path

below i give the running code, as the ant build file: all you have to to is getting some suitable images

NOTE: this code works as it is - i mean without the use of packages; i'll open another topic concerning this last case



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic