java - Load a config file into the classpath while using an executable jar -
i building assembly in maven command line utility. can run executable jar, fails because need load config file externally. assuming following config, how run jar?
- jar in /opt/myapp/lib/myapp-assembly.jar
- config in /etc/myapp/config/settings.xml
- i'm loading code classpath using classpathresource("/settings.xml");
any appreciated!
i see 2 ways it:
- launch program using jar archive rather executable jar, specifying main class @ run time. in other words, java -classpath /opt/myapp/lib/myapp-assembly.jar:/etc/myapp/config [name of main class].
- use class-path field of jar manifest file. entries in directly added run time classpath, , there's nothing stopping specifying filesystem directory rather jar file. manifest contain: class-path: /etc/myapp/config/
Comments
Post a Comment