permaculture playing cards*
The moose likes Ant, Maven and Other Build Tools and the fly likes image is missing when jaring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "image is missing when jaring" Watch "image is missing when jaring" New topic
Author

image is missing when jaring

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
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?


java amateur
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
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

Joined: May 14, 2008
Posts: 5836
    
    7

How is this question different from this one:
http://www.coderanch.com/t/469220/Ant-Maven-Other-Build-Tools/jaring-images-folder


JBoss In Action
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
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

Joined: Feb 08, 2004
Posts: 1281
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



 
 
subject: image is missing when jaring