This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How to find a path as a string to a resource

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
I did a little bit different from your version. But it did work



Thanks for your info
Jack
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!