Reputation: 66156
We can pass a single property through java CLI using -D
argument:
java -Dkey=value ...
Is there a way to pass all properties from a property file in that way?
Something like:
java -Dprop.file=myproperties.properties ...
Upvotes: 0
Views: 1996
Reputation: 26180
There is no such option for java cli.
But this task can be achieved from command line with simple ant's build.xml using loadproperties and syspropertyset.
Upvotes: 0
Reputation: 24630
In your code with
new Properties().load(...)
of course, but from command line the doc talks only about key=val
Be aware that there are some keys (eg. java.library.path) that must be set before your program runs and reseting in your code will have no effect.
Upvotes: 0
Reputation: 533520
You can if you add
System.getProperties().load(new FileInputStream(System.getProperty("prop.file")));
Upvotes: 3