this topic is in a way the continuation of this one
the diference is this: i added each class to a package (gui and util)
in first place i had to change the path to the frame icon image from:
"thisImage" to
"/thisImage"
the others didnt need this fix
now, if i run, i get it all ok, but, if i jar, only the tab images appear; the frame icon and the panel background dont show up
so here´s the reason for this topic: i tried gazillions paths to images, but couldnt find a proper solution
i suspect the path to images is related to the way the code searches for the images in the classpath, but i'v not enough java knowleadge to sort it out
Post the contents of the img.jar file. To do that, run this:
jar -tf jars/img.jar
It appears that you are attempting to load the images as resources form the classpath. I assume that img.jar is in your classpath and that all of the images are in the base directory of the jar file.
By the way, I found the code you posted extremely difficult to read because of the extra blank lines. I deleted them for you this time, but if you want answers to your questions you need to make it as easy for the readers of the forum as possible, otherwise those readers might skip your post. This is especially true if you post a lot of code.
Peter Johnson wrote:Post the contents of the img.jar file. To do that, run this:
jar -tf jars/img.jar
It appears that you are attempting to load the images as resources form the classpath. I assume that img.jar is in your classpath and that all of the images are in the base directory of the jar file.
By the way, I found the code you posted extremely difficult to read because of the extra blank lines. I deleted them for you this time, but if you want answers to your questions you need to make it as easy for the readers of the forum as possible, otherwise those readers might skip your post. This is especially true if you post a lot of code.
hi Peter, thanks for helping
i indeed thought spaced code was more readable , but no problem
i'm extremely happy because i found a working and perfect solution, based on this marvelous book i was lucky enough to win here at javaranch book promotions: Agile java, by Jeff Langr
but before i drop the solution, let me properly answer you:
It appears that you are attempting to load the images as resources form the classpath.
yes! - and that's the point (i guess) - im trying to load the images as resources from the classpath -that pointed me to the right solution: using the very same code (as possible) to display the images
I assume that img.jar is in your classpath
i've that jar commented out from classpath, for now only (jar.dir)
yet i'm (still) not using the jared images folder (that will be my next goal) - i'm using the images folder (img) placed inside "source" folder and moving it to the "classes" folder
here's the content of the imgjar:
C:\javagranel\Teste>jar -tf jars/img.jar
META-INF/
META-INF/MANIFEST.MF
Thumbs.db
clear.png
criarLancamento.png
jr2.jpg
radar.jpg
(half an hour later)
now i'm ever happier, because i can run a jar getting it perfectly, using either the img folder or the imgjar.jar as well in the code i show i have the imgjar in the classpath and the img folder out if it (anyway it works both ways)
(the build file isnt perfect yet because i need a jarimg created in order to run the application and now i'm not seizing the correct solution, but anyway i'm sure all works fine - got a family life too, so in the next days i'll fix it)