• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Loading from a resource folder returns null

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic