how to pass list of arguments to VM command line

2019-09-07 16:23发布

问题:

I want to pass 2 dynamic VM argument, how?

to pass one dynamic argument i use:

 java -Dxxxxxxxx=xxxx main

but how to pass more than 1 argument.

Thanks.

回答1:

From Java:

-Dproperty=value

  • Sets a system property value.
  • If value is a string that contains spaces, then you must enclose the string in double quotation marks:

java -Dmydir="some string" SomeClass

In your command line:

java -cp . -Djava.security.auth.login.config=./loginmodules.properties -Djava.security.policy=. chp02.policy -Djava.security.manager chp02.Chp02Main

the second argument -Djava.security.policy=. chp02.policy contains a space.

You need to enclose with " or correct the argument if the space is a mistake.