zoukankan      html  css  js  c++  java
  • 【提问】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

    哪位大牛遇到过

  • 相关阅读:
    安装Joomla!3
    keepalived + lvs
    systemd 服务介绍
    lvs 进阶 第二章
    lvs 初始 第一章
    iptables 最终 第四章
    bind 笔记
    iptables 扩展匹配 第三章
    iptables 认识 第二章
    iptables 初见 第一章
  • 原文地址:https://www.cnblogs.com/dw729/p/3443677.html
Copyright © 2011-2022 走看看