Passing whole file to JVM arguments

I have several systems that all must load the same properties into 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 of the whole file in one go. For instance:

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

Thank,

EDIT: Any arguments or commands should also work in a Windows environment. Therefore, any bash or unix-specific scripting hacks will not work.

+5
source share
4 answers

, :

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

options_file -Dsomething -Xsomething, . tr .

+6

, ( - bash , ), :

-DmyPropertiesFile=/your/properties/file.properties, Properties.load(). System.setProperties(yourProps) , .

, , , (, main() , ).

+7

:

  • .jar , getClass().getResourceAsStream()
  • Java -D, .

Spring ( ) PropertyPlaceholderConfigurer. Spring .

+3

Ant lanuch Java, 9000 ( ) , .

StackOverflow , , ant

0

All Articles