User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 332,573 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,127 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 372 | Replies: 15
Reply
Join Date: May 2007
Location: USA
Posts: 2,197
Reputation: Ezzaral is a jewel in the rough Ezzaral is a jewel in the rough Ezzaral is a jewel in the rough 
Rep Power: 7
Solved Threads: 211
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Postaholic

Re: Loading images from executable jar file?

  #11  
8 Days Ago
I would try to verify that the images package(directory) is actually in the jar file. Depending upon how you created the jar, those files may have gone into the root of the jar, in which case "images/flag2.gif" would not resolve correctly.
Reply With Quote  
Join Date: May 2008
Posts: 23
Reputation: TheWhite is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
TheWhite TheWhite is offline Offline
Newbie Poster

Re: Loading images from executable jar file?

  #12  
8 Days Ago
jar cmf mainClass.txt MineSweeper.jar *.class images/*.gif

puts the folder there and everything... Extracted it too, it's there...
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 2,197
Reputation: Ezzaral is a jewel in the rough Ezzaral is a jewel in the rough Ezzaral is a jewel in the rough 
Rep Power: 7
Solved Threads: 211
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Postaholic

Re: Loading images from executable jar file?

  #13  
7 Days Ago
Not sure what to tell you then, because that exact jar structure and loading code works just fine for me.
Reply With Quote  
Join Date: May 2008
Posts: 23
Reputation: TheWhite is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
TheWhite TheWhite is offline Offline
Newbie Poster

Re: Loading images from executable jar file?

  #14  
7 Days Ago
Here, maybe you can take a look at my code... I cut out most of the gooie/extra stuff so you can text it out..

Right clicking should show a flag then a ? then nothing.

If you extract the jar file, you will find my source code, the images, and the compiled .class files. If you run it, the program runs, but the icons dont show.
http://www.fileden.com/files/2008/2/...ineSweeper.jar

I'm not using getResource atm so extracting the jar and moveing the image folder next to the jar will show icons. When I try to use getClass().getResource(), i get nullpointererror...

Hopefully this helps you see what I see..
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 2,197
Reputation: Ezzaral is a jewel in the rough Ezzaral is a jewel in the rough Ezzaral is a jewel in the rough 
Rep Power: 7
Solved Threads: 211
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Postaholic

Re: Loading images from executable jar file?

  #15  
7 Days Ago
Changing that code to use getClass().getResource() works perfectly on my machine. Attaching the revised jar (I had to put it in a zip file since it won't allow me to attach a .jar)
Attached Files
File Type: zip MineSweeper.zip (7.1 KB, 1 views)
Reply With Quote  
Join Date: May 2008
Posts: 23
Reputation: TheWhite is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
TheWhite TheWhite is offline Offline
Newbie Poster

Re: Loading images from executable jar file?

  #16  
7 Days Ago
copying the code right out of the java file into eclipse gave me the same problem so I decided to delete the entire project and start copying the code from the java files from scratch. Now it's working.....

meh.. Thanks for all your time and help Ezzaral. you deserve more rep points
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Other Threads in the Java Forum

All times are GMT -4. The time now is 12:35 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC