I have a JAR file that contains an application as well as configuration files for that application. The application loads configuration files from the classpath (using ClassLoader.getResource()
), and has its dependencies completely satisfied using the configuration files baked into the JAR file.
On occasion I want the application to be run with a slightly different configuration (specifically I want to override the JDBC URL to point to a different database) so I create a new configuration file, store it in the correct directory structure (which means in a directory /config
of a classpath entry), and I want to do something like this:
java -cp new-config:. -jar application.jar
But I can't get the classpath to have the new-config
path entry before the application JAR's contents. Is it hard-coded that the JAR's content is always the first thing on the classpath?