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
- src -klass.java
- bin -klass.class
- resource
lib
public class Klass { public void resourceTest() { ClassLoader.getSystemResource(Klass.class.getSimpleName() + ".class").toString(); Klass.class.getClass().getResource(Klass.class.getSimpleName() + ".class").toString(); Klass.class.getClass().getClassLoader().getResource(Klass.class.getSimpleName() + ".class").toString(); } }
Please let me know if I'm doing anything wrong. I've used getResource
before so this is driving me crazy. Thanks!