给定以下课程:
public class SpecifySystemPropertiesCommandLine {
public static void main(String[] args) {
String prop1 = System.getProperty("prop1", "defaultvalue");
String prop2 = System.getProperty("prop2", "defaultvalue");
System.out.println("prop1 = " + prop1);
System.out.println("prop2 = " + prop2);
}
}
为什么以下不起作用:
$ java -jar sysprop.jar -Dprop1="i can haz?"
prop1 = defaultvalue
prop2 = defaultvalue
但这有效:
$ java -Dprop1="i can haz?" -jar sysprop.jar
prop1 = i can haz?
prop2 = defaultvalue