官方解釋
Set a system property value. If value is a string that contains spaces, you must enclose the string in double quotes:
java -Dfoo="some string" SomeClass
讀取方法
public class TestSystem {
public static void main(String args[]) {
System.out.println(System.getProperty("a.b.c"));
}
}
在運行改程序時加上JVM參數-Da.b.c="1234",那么運行之后你可以看到控制台輸出了1234!
一點值得注意的是,需要設置的是JVM參數而不是program參數,注意看下圖

這里的program arguments指的是main方法中的args數組~
