Passing an entire file to JVM arguments

doug picture doug · Feb 1, 2011 · Viewed 14.6k times · Source

I have several systems that all need to load the same properties to the JVM. I can use the -D flag to load one property at a time, but i am looking for something that will load all the properties in an entire file at one time. For instance:

I could just add --options-file=blah.properties to all jvms on my network, once, and from then on only change the properties file, which could be a single central file over a network share.

Thank you,

EDIT: Any arguments or commands must also work in a windows environment. Therefore any bash or scripting hacks specific to unix will not work.

Answer

9000 picture 9000 · Feb 1, 2011

That's roughly how we do it:

java $(tr '\n' ' ' < options_file) other args...

Here options_file contains ready -Dsomething or -Xsomething values, one per line. The tr command just replaces every newline with a space.