<small id='PiaAn'></small><noframes id='PiaAn'>

  • <legend id='PiaAn'><style id='PiaAn'><dir id='PiaAn'><q id='PiaAn'></q></dir></style></legend>

      <bdo id='PiaAn'></bdo><ul id='PiaAn'></ul>

      <tfoot id='PiaAn'></tfoot>
      <i id='PiaAn'><tr id='PiaAn'><dt id='PiaAn'><q id='PiaAn'><span id='PiaAn'><b id='PiaAn'><form id='PiaAn'><ins id='PiaAn'></ins><ul id='PiaAn'></ul><sub id='PiaAn'></sub></form><legend id='PiaAn'></legend><bdo id='PiaAn'><pre id='PiaAn'><center id='PiaAn'></center></pre></bdo></b><th id='PiaAn'></th></span></q></dt></tr></i><div id='PiaAn'><tfoot id='PiaAn'></tfoot><dl id='PiaAn'><fieldset id='PiaAn'></fieldset></dl></div>

      1. System.getenv() &amp; 之间的区别System.getProperty()

        时间:2023-07-13
        <i id='IXCwK'><tr id='IXCwK'><dt id='IXCwK'><q id='IXCwK'><span id='IXCwK'><b id='IXCwK'><form id='IXCwK'><ins id='IXCwK'></ins><ul id='IXCwK'></ul><sub id='IXCwK'></sub></form><legend id='IXCwK'></legend><bdo id='IXCwK'><pre id='IXCwK'><center id='IXCwK'></center></pre></bdo></b><th id='IXCwK'></th></span></q></dt></tr></i><div id='IXCwK'><tfoot id='IXCwK'></tfoot><dl id='IXCwK'><fieldset id='IXCwK'></fieldset></dl></div>
        <tfoot id='IXCwK'></tfoot>

            <tbody id='IXCwK'></tbody>
        1. <legend id='IXCwK'><style id='IXCwK'><dir id='IXCwK'><q id='IXCwK'></q></dir></style></legend>
            <bdo id='IXCwK'></bdo><ul id='IXCwK'></ul>

                  <small id='IXCwK'></small><noframes id='IXCwK'>

                  本文介绍了System.getenv() &amp; 之间的区别System.getProperty()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可能重复:
                  系统属性和环境变量有什么区别

                  System.getenv() & 有什么区别?System.getProperty()?

                  What is the difference between System.getenv() & System.getProperty()?

                  当我们使用 Processbuilder 运行任何命令时,我们可以设置环境变量,即:

                  When we run any command using Processbuilder, we can set the environment variables ie:

                  String[] vCmd = { System.getenv("ANT_HOME") + "/bin/ant", "-f",
                                  ANT_BUILD_FILE, TARGET };
                          ProcessBuilder pb = new ProcessBuilder(vCmd);
                          Map<String, String> env = pb.environment();     
                          env.put("CLASSPATH",
                                  antHome+"/lib/ant.jar:"
                                          + antHome+"/lib/ant-launcher.jar:"
                                          + antHome+"/lib/ant-nodeps.jar:"
                                          );
                          try{
                  
                              Process process = pb.start();
                              InputStream is = process.getInputStream();
                              InputStreamReader isr = new InputStreamReader(is);
                              BufferedReader br = new BufferedReader(isr);
                              String line;
                              while ((line = br.readLine()) != null) {
                                  System.out.println(line);
                              }
                              pb.wait();
                          }
                          catch(Exception e)
                  
                              System.out.println(e.getMessage());
                  
                  
                          }
                  

                  如果我在这个方法之前使用 System.setProperties() 设置了一些属性,它是否可用于由 ProcessBuilder 启动的这个进程?

                  If I set some properties using System.setProperties() before this method , is it available to this process started by ProcessBuilder?

                  推荐答案

                  System.getenv 得到一个环境变量.System.getProperty 获取 Java 属性.环境变量在操作系统级别指定.Java 属性是通过将 -D 选项传递给 JVM 来指定的(并且可以通过编程方式设置).

                  System.getenv gets an environment variable. System.getProperty gets a Java property. Environment variables are specified at the OS level. Java properties are specified by passing the -D option to the JVM (and can be set programmatically).

                  这篇关于System.getenv() &amp; 之间的区别System.getProperty()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:内部类与静态嵌套类的 GC 性能下降 下一篇:从 logback 配置文件中读取环境变量

                  相关文章

                    <i id='JJDdj'><tr id='JJDdj'><dt id='JJDdj'><q id='JJDdj'><span id='JJDdj'><b id='JJDdj'><form id='JJDdj'><ins id='JJDdj'></ins><ul id='JJDdj'></ul><sub id='JJDdj'></sub></form><legend id='JJDdj'></legend><bdo id='JJDdj'><pre id='JJDdj'><center id='JJDdj'></center></pre></bdo></b><th id='JJDdj'></th></span></q></dt></tr></i><div id='JJDdj'><tfoot id='JJDdj'></tfoot><dl id='JJDdj'><fieldset id='JJDdj'></fieldset></dl></div>

                        <bdo id='JJDdj'></bdo><ul id='JJDdj'></ul>
                    1. <small id='JJDdj'></small><noframes id='JJDdj'>

                      <legend id='JJDdj'><style id='JJDdj'><dir id='JJDdj'><q id='JJDdj'></q></dir></style></legend><tfoot id='JJDdj'></tfoot>