Please take a step back. Your specific problem is that the resource returns null
, right? Are you sure his path is right? Like you, this applies to the package of the current class. Shouldn't the path start with /
relative to the package root?
URL resource = getClass().getResource("/rsc/my_resource_file.txt");
Alternatively, you can also use the context class loader, it always refers to the root of classpath (package):
ClassLoader loader = Thread.currentThread().getContextClassLoader(); URL resource = loader.getResource("rsc/my_resource_file.txt");
At least the Eclipse launcher is not to blame.
source share