java - Is it possible to load different config files on starting .jar? -
my question .jar file. in project use json config file, loaded in .jar file. possible somehow can use different config files ? have project done server/client sockets, , know have many clients, don't want create many client.jar each config file, want use 1 main client.jar , run different config files.
if can't understand i'll try explain in example :
maybe it's possible make custom flag or something?
java -jar -config client.jar example/foo/config.json java -jar -config client.jar example/foo/config2.json
and on... guess me.. :)
two options here:
- pass file name argument,
- pass system property
option 1:
you run jar this:
java -jar client.jar example/foo/config.json
and filename in first argument of main(string[] args)
method.
option 2:
you run jar this:
java -dconfig=example/foo/config.json -jar client.jar
and file name calling system.getproperty("config")
.
the second method have advantage of letting file name available anywhere in program, whereas first on makes available in main method.
Comments
Post a Comment