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:

  1. pass file name argument,
  2. 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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -