• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to find a path as a string to a resource

 
Jacky Luk
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?
 
Palraj Jayaraj
Ranch Hand
Posts: 36
Chrome Eclipse IDE 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
Chrome Eclipse IDE 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic