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.
Configure JVM options From the main menu, select Help | Edit Custom VM Options. If you do not have any project open, on the Welcome screen, click Configure and then Edit Custom VM Options. If you cannot start IntelliJ IDEA, manually copy the default file with JVM options to the IntelliJ IDEA configuration directory.
-- Go to the Eclipse Window > preferences, in "Java > Installed JREs". -- Copy the current default JRE with a new name, for example myJRE. -- Select the new JRE and click on the "Edit" button. -- In the "Edit JRE" dialog, add your JVM arguments in the "Default VM Arguments" field.
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.
I don't think you can do that via the command line (without some bash hacks, perhaps), but you definitely can do that programatically:
Simply set one property -DmyPropertiesFile=/your/properties/file.properties
and then read that with one of the Properties.load()
overloads. After that, System.setProperties(yourProps)
should do what you expect.
Of course, this requires that you can hook this code early enough so that your properties will be available when needed (For instance, if the main()
method is yours, this is perfect).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With