如何在java中添加新的系统属性

Nel*_*elo 24 java properties system-properties

是否可以向Java系统属性添加新值.如果有任何可以在Java系统属性中引入具有相应值的新密钥.

dty*_*dty 43

在启动JVM时使用System.setProperty或使用该-Dname=value标志


ass*_*ias 7

是:

public static void main(String args[]) {
    String key = "a new property";
    System.setProperty(key, "a property with a value");
    System.out.println(System.getProperty(key));
}
Run Code Online (Sandbox Code Playgroud)