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?

  1. jar in /opt/myapp/lib/myapp-assembly.jar
  2. config in /etc/myapp/config/settings.xml
  3. i'm loading code classpath using classpathresource("/settings.xml");

any appreciated!

i see 2 ways it:

  1. 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].
  2. 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

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -