Load resource from anywhere in classpath
java
Solution
If all else fails you could use two different file names, say `props-default.properties` inside `myJar.jar` and `props.properties` to override on the command-line. In your code, you'd try loading the `props.properties` file first and fallback to `props-default.properties` if it wasn't found.
Problem
I have a simple java application that loads a properties file from the current package. ``` this.getClass().getResourceAsStream("props.properties"); ``` This works fine when the property file I want is in the current package. However, I want to package this application as a JAR and define and override with a new properties file where I use it. Is there a way to load the first resource named "props.properties" that is on the classpath? I want it to be as easy to override the properties file via command line: ``` java.exe -classpath props.properties;myJar.jar com.test.MyApp ``` I don't want to have to unpack the JAR and modify the properties file to change something. I feel like I'm missing something obvious...