Don't flag as duplicate yet!
Hear me out; all of the solutions that I have seen are good, but I don't understand how the class paths work when loading resources using:
ClassLoader classLoader = getClass().getClassLoader()
I want to set up a resource loader (named ResourceLoader
) that can load from anywhere within the jar package.
So if the loader is placed in com.spikespaz.engine.loader.ResourceLoader
, I don't want to be stuck in the relative path of com.spikespaz.engine.loader
.
I want to be able to load from com.spikespaz.game.resources.textures
and com.spikespaz.game.resources.models
without the need to put a reader in the parent directory.
What I found is this: https://stackoverflow.com/a/3862115/2512078
But from what I understood, all of those options in his answer must be relative to the class loading them. (getClass()
) Is there a way around this, or am I misunderstanding it?
If I am misunderstanding it, could someone explain better?
Any solutions must be relative to the exact root of the jar package or source of the development environment, and I must not need to put anything in that root.
Thanks.