user3194585
user3194585

Reputation: 33

getResource causing NullPointerException

I know there have been multiple posts on the subject but my issue seems to be one that hasn't been brought up yet. Under no circumstance can I seem to get getResource to correctly return a path location. It got to the point where I try to find the current class' path and even that is giving me a null pointer exception. Here is a list of ways I have went about it.

testProject

Please let me know if I'm doing anything wrong. I've used getResource before so this is driving me crazy. Thanks!

Upvotes: 1

Views: 609

Answers (2)

Russell Zahniser
Russell Zahniser

Reputation: 16364

Klass.class.getClass() is equivalent to Class.class, since the class of Klass.class is Class. So this would be trying to load a resource in the java.lang package. You just want Klass.class.getResource().

Upvotes: 2

Tonino
Tonino

Reputation: 1166

There is a klass.class as last row. Try to use Klass.class with capital K

Upvotes: -1

Related Questions