1

I have a utility project file that I've put code in for loading resource files. However, when I reference this project from a different one to use this loading code, the loader still uses its own src folder, instead of the src folder of the project referencing it.

I'm loading all my resources like this: ClassLoader.class.getResourceAsStream(filepath) ...where filepath might be something like "/res/index.txt"

My first guess as to how to make this work would be to use a different class in the project I want to load from instead of the ClassLoader to get resources? What would the most elegant solution to this be?

I am using Netbeans, if that makes a difference.

leopardGeckos
  • 91
  • 2
  • 8

1 Answers1

0

If you use "/" in the beginning of filepath, it's gonna be resolved from the package root (it is clearly stated in the JavaDocs).

Try to make your build script copy the resources to the bin directory (IIRC NetBeans was compiling with Ant scripts, haven't used it for a while).

rlegendi
  • 10,466
  • 3
  • 38
  • 50