Map m = System.getenv(); for ( Iterator it = m.keySet().iterator(); it.hasNext(); ) { String key = (String ) it.next(); String value = (String ) m.get(key); System.out.println(key +":" +value); } System.out.println( "--------------------------------------" ); Properties p = System.getProperties(); for ( Iterator it = p.keySet().iterator(); it.hasNext(); ) { String key = (String ) it.next(); String value = (String ) p.get(key); System.out.println(key +":" +value); }
在命令行执行,能够获取到pc所有的环境变量
在eclipse上运作,只能获取到pc原有的一些环境变量(后添加的都没有获取到)。导致Process process = Runtime.getRuntime().exec("adb shell getprop ro.product.brand"); 这样的操作,报错:Cannot run program "adb": error=2, No such file or directory
哪位大牛遇到过