Is there an easier way to specify multiple System Properties on the command line to a Java program rather than having multiple -D statements?
Trying to avoid this:
java -jar -DNAME="myName" -DVERSION="1.0" -DLOCATION="home" program.jar
I thought I had seen an example of someone using one -D
and some quoted string after that, but I can't find the example again.
If the required properties need to set in system then there is no option than -D But if you need those properties while bootstrapping an application then loading properties through the proerties files is a best option. It will not require to change build for a single property.
Answer is NO. You might have seen an example where somebody would have set something like :
-DArguments=a=1,b=2,c=3,d=4,e=cow
Then the application would parse value of
Arguments
property string to get individual values. In yourmain
you can get the key values as(Assuming input format is guaranteed):Also, the
-D
should be before the main class or thejar
file in the java command line. Example :java -DArguments=a=1,b=2,c=3,d=4,e=cow MainClass
You may be able to use the
JAVA_TOOL_OPTIONS
environment variable to set options. It worked for me with Rasbian. See Environment Variables and System Properties which has this to say:However this environment variable use may be disabled for security reasons.
See this example showing the difference between specifying on the command line versus using the
JAVA_TOOL_OPTIONS
environment variable.There's nothing on the Documentation that mentions about anything like that.
Here's a quote:
Instead of passing the properties as an argument, you may use a .properties for storing them.