Topic: System.getProperty的问题? |
Print this page |
1.System.getProperty的问题? | Copy to clipboard |
Posted by: whlxy Posted on: 2004-04-13 14:24 public class test { public static void main(String[] args) { System.out.println(System.getProperty( "test.initscript")); System.out.println(System.getProperty( "java.version")); } } the result is: null 1.3.1_10 如何自己设置一个系统非默认的property,如test.initscript="123456", 使上面的程序输出结果为: 123456 1.3.1_10 谢谢! |
2.Re:System.getProperty的问题? [Re: whlxy] | Copy to clipboard |
Posted by: kavenlin Posted on: 2004-04-13 14:27 java -Dtest.initscript=123456 test |
3.Re:System.getProperty的问题? [Re: whlxy] | Copy to clipboard |
Posted by: whlxy Posted on: 2004-04-13 15:31 谢谢您的rapid response!在命令行上通过。 我用的是Eclipse, RUN->run->arguments 然后在program arguments里,写上了: test.initscript=123456 but,the result still is: null 1.3.1_10 请问,在program arguments里,应如何填写。 另外,有无可能不通过命令行的方式,而采用调用property文件的方式,来采集这个参数? |
4.Re:System.getProperty的问题? [Re: whlxy] | Copy to clipboard |
Posted by: erongd Posted on: 2004-04-13 16:14 In Eclipse you have to put the property in "VM Arguments". -Dtest.initscript=123456. In order to load it from property file, you have to create a <name>.properties file then load it through ResourceBoundle class. |
5.Re:System.getProperty的问题? [Re: whlxy] | Copy to clipboard |
Posted by: bluebangbang Posted on: 2004-04-13 18:38 Properties prop = new Properties(); prop.setProperty(initscript,123456); System.setProperties(prop); |
6.Re:System.getProperty的问题? [Re: whlxy] | Copy to clipboard |
Posted by: whlxy Posted on: 2004-04-13 19:20 thank you! |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |