I have a properties file that I've included within a jar I'll be distributing. Before I decided to include the file within the jar I was loading it like
properties.load(new FileInputStream(configFileName)); But this stopped working once the file was placed inside the jar so I changed the code to
properties.load(MyClass.class.getResourceAsStream(configFileName)); Only problem is I have unit tests that use my properties (which are loaded statically so I can't mock it). The unit tests are run before the jar is made so they all fail now. Is there an elegant way to handle a file that will be in a jar only if the program is run as a jar?