getResourceAsStream returns null
Lifepaths.class.getClass().getResourceAsStream(...)
loads resources using system class loader, it obviously fails because it does not see your JARs
Lifepaths.class.getResourceAsStream(...)
loads resources using the same class loader that loaded Lifepaths class and it should have access to resources in your JARs
The rules are as follows:
- check the location of the file you want to load inside the JAR (and thus also make sure it actually added to the JAR)
- use either an absolute path: path starts at the root of the JAR
- use an relative path: path starts at the package directory of the class you're calling getResource/ getResoucreAsStream
And try:
Lifepaths.class.getResourceAsStream("/initialization/Lifepaths.txt")
instead of
Lifepaths.class.getClass().getResourceAsStream("/initialization/Lifepaths.txt")
(not sure if it makes a difference, but the former will use the correct ClassLoader/ JAR, while I'm not sure with the latter)