Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get the Path of An Image??

807580Jan 20 2010 — edited Jan 20 2010
Ok, so I have been looking for a simple solution for an hour now and i'm fed up.
I hope you guys can help.

I have a zip folder called "Resources.zip"
Inside this zip folder is a folder called "res" (NetBeans sees "res" as a package inside Resources.zip)
inside the "res" folder are x number of images (.png)
Inside NetBeans I imported the Resources.zip folder to be included in the Libraries.

Now in one of the classes as seen bellow I try to (after fiddling around with the path) refer to 3 images in the Resources.zip folder:
        lblProduct.setIcon(new ImageIcon("Resources.zip/res/Product.png"));
        pnlProduct.add(lblProduct);


        lblDivision.setIcon(new ImageIcon("Resources.zip/res/Division.png"));
        pnlDivision.add(lblDivision);


        lblPower.setIcon(new ImageIcon("Resources.zip/res/Power.png"));
        pnlPower.add(lblPower);
When I run the whole application from NetBeans the path seems to work and the images are visible.

Now the problem is when I Build&Clean the whole project which creates a /dist directory containing the complied and execulatble .Jar file for the application AND a folder called "lib" which contains the Resource.Zip folder

Now the problem is when I run the application through the .jar file in the dist/ directory the images simply wont load...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 17 2010
Added on Jan 20 2010
4 comments
107 views