Java怎么设置系统参数和运行参数
lewis
2017-02-20
21次阅读
在Java中,可以使用System类的setProperty()方法来设置系统参数,例如:
System.setProperty("key", "value");
可以使用System类的getProperty()方法来获取系统参数,例如:
String value = System.getProperty("key");
对于运行参数,可以在命令行中使用"-D"选项来指定,例如:
java -Dkey=value Main
然后在Java代码中可以使用System类的getProperty()方法来获取运行参数,例如:
String value = System.getProperty("key");

发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。