I have a project that I am compiling using javac
. I want to be able to fetch resources without having to first build my project into a JAR file, but at the same time, I don't want to hard code the location either (C://Users/name/etc).
I know that if I had a JAR file, I could use a ClassLoader
and call one of the resource methods from there. Alternatively, if my resources were contained within another JAR file, and that JAR file was on my class path, then I could fetch it from the JAR file in a similar format.
But how do I do so when I am only compiling in javac? I don't want to have to rework all of my resource fetching logic when I eventually turn this into a JAR file, but I also don't want to have to make a jar file every time I compile and want to test a change. I just want to be able to specify to Java that this is where to find my resources, and I don't want to change that strategy when I finally decide to making a JAR file.