Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How to find a path as a string to a resource

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Throws an exception, nullPointerException

I have my resources under


Any ideas?
 
Ranch Hand
Posts: 36
Eclipse IDE Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My advice is to have the 'resources' folder under the default package.

and try the below code:

I hope this works
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Palraj Jayaraj wrote:My advice is to have the 'resources' folder under the default package.

and try the below code:

I hope this works



Hi Palray,
I am afraid that still doesn't work. I have attached an image for your reference
resources-folder.png
[Thumbnail for resources-folder.png]
 
Palraj Jayaraj
Ranch Hand
Posts: 36
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Jacky,

While creating a program, I had an excel sheet under a folder named 'a' in 'resources' folder, under 'src' folder'.

When I ran the program, I also got a Null-Pointer Exception.

Please refer to the attachments named:

in Folder a_Eclipse.jpg: https://docs.google.com/file/d/0BzcpOxYvgyz3b0cwNkpMdmFiZk0/edit?usp=sharing

in Folder a_Explorer.jpg: https://docs.google.com/file/d/0BzcpOxYvgyz3cVRJNk5hNGxveHc/edit?usp=sharing




But, when I had the same excel under the 'resources' folder itself (in 'src' folder), I did not get any errors.

Please refer the attachments named:

without Folder a_Eclipse.jpg: https://docs.google.com/file/d/0BzcpOxYvgyz3WjVQMFdMMENoQmM/edit?usp=sharing

without Folder a_Explorer.jpg: https://docs.google.com/file/d/0BzcpOxYvgyz3RHdsaDhNdW9HcUU/edit?usp=sharing





have the image under 'resources' and run the program. It should solve the problem.

It is weird though, I'm not aware of the root cause. But, it should solve your problem
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did a little bit different from your version. But it did work



Thanks for your info
Jack
 
I am mighty! And this is a mighty small ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic