Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getClass().getClassLoader().getResource(path) always return null, even when the path is correct

 
Daniel Gallant
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having an issue with the following code. the getClass().getClassLoader().getResource(path) always throws an exception, but the path used (and printed in the error message) are correct.



Thanks for all your help!
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Daniel,

"Correct" can be a relative term! The path should be relative to a location on the classpath; i.e., it's a path from the root of a jar file, or a path from the directory on the classpath. An absolute path from the root of your disk (for instance) will not work.
 
Daniel Gallant
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
D'Oh!!

I knew it would be something simple.

Thanks for your help! I really appreciate it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic