【提问】java获取环境变量的代码,mac机器上命令行运行和eclipse运行的不同

            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

 

哪位大牛遇到过

 

posted on 2013-11-26 17:00  邓伟  阅读(753)  评论(2编辑  收藏  举报

导航