permaculture playing cards*
The moose likes Ant, Maven and Other Build Tools and the fly likes need help to find the right path to images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "need help to find the right path to images" Watch "need help to find the right path to images" New topic
Author

need help to find the right path to images

miguel lisboa
Ranch Hand

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



can anyone help me, please?

just in case, here's the running code:


and the ant build file:


java amateur
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5812
    
    7

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.


JBoss In Action
miguel lisboa
Ranch Hand

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

ok, so, time for revealing the code:


ant the ant build file:


so it's a case sloved!

have a nice weekend!


[Download junior.bmp] Download

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: need help to find the right path to images
 
Similar Threads
jaring an images folder
image is missing when jaring
Drawing with mouse
centering a dialog
Focus: cant find the relevant method