Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading from a resource folder returns null

 
john merritt
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic