aspose file tools*
The moose likes Beginning Java and the fly likes Loading from a resource folder returns null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Loading from a resource folder returns null" Watch "Loading from a resource folder returns null" New topic
Author

Loading from a resource folder returns null

john merritt
Greenhorn

Joined: Aug 24, 2009
Posts: 14
Couldn't find file: resource\images\el.png. Couldn't find file: resource\images\er.png
I have created a resource\folder folder that shows up in the NetBeans files window displaying the files contained.
The path coded matches the path on my PC.
When I try and load the files it returns null.
Can somebody please point out what I am doing wrong with this code?
Thanks
John



John, the recycled hippy, many times over.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Since you're using a relative path, it's likely the execution directory isn't the one you believe it is.
Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
Hi,

I use this:

I create resource folder in the source tree in Netbeans, not in the files window,
and it works fine - Netbeans packs this folder together with files into the jar,
and the code above loads the files from jar.
john merritt
Greenhorn

Joined: Aug 24, 2009
Posts: 14
Thanks for the reply guys. I apologise for my delay in responding; due to a health problem/disability I am not always well enough to work on the PC. Thanks for the advice I am no longer getting a null hopefully indicating the png files are being found and loaded ok. Only problem now is graphics are not being displayed in the labels. However I use this forum, as last port of call, so will spend time analysing my code to see where I have coded in error before returning. Thanks once again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading from a resource folder returns null
 
Similar Threads
Escape sequences
problem with MyClass.class.getResource()
loading image
GIF image not getting displayed from an executable jar
Loading an Image