首页 > 其他分享 >program arguments,vm arguments,environment variable

program arguments,vm arguments,environment variable

时间:2022-11-01 06:55:05浏览次数:45  
标签:getProperty System getenv environment println arguments variable out

作者:david_zhang@sh 【转载时请以超链接形式标明文章】

https://www.cnblogs.com/david-zhang-index/p/16846493.html

参数太多,傻傻分不清楚,简单说

1,program arguments是main函数args[]参数

2,vm arguments是java环境变量

3,environment variable是jvm环境变量

看代码如何获取这些参数:

public class TestProgram {
    public static void main(String[] args) {
        // program arguments对应的args参数
        for (String arg : args) {
            System.out.println(arg);
        }
        System.out.println("==============program arguments对应的args参数===============");
        System.out.println();

        // getProperty()获取java的环境变量
        String value1 = System.getProperty("key1");
        String value2 = System.getProperty("key2");
        System.out.println("System.getProperty(\"key1\")----->" + value1);
        System.out.println("System.getProperty(\"key2\")----->" + value2);
        Properties properties = System.getProperties();
        System.out.println("System.getProperties():=======>" + properties);
        System.out.println("==============getProperty()获取java的环境变量===============");
        System.out.println();


        // 获取运行jvm环境变量
        System.getenv();
        Map<String, String> getenv = System.getenv();
        System.out.println("System.getenv():----->" + getenv);
        String env1 = System.getenv("env1");
        String env2 = System.getenv("env2");
        System.out.println("System.getenv(\"env1\")=======>" + env1);
        System.out.println("System.getenv(\"env2\")=======>" + env2);
        System.out.println("===============获取运行jvm环境变量===============");
        System.out.println();
    }
}

-argu=111
-arge=222
==============program arguments对应的args参数===============

System.getProperty("key1")----->v1
System.getProperty("key2")----->v2

==============getProperty()获取java的环境变量===============

System.getenv("env1")=======>test
System.getenv("env2")=======>prod
==============获取运行jvm环境变量===============

参数设置

 总结:

System.getProperty();

System.getProperties();

System.getenv();

标签:getProperty,System,getenv,environment,println,arguments,variable,out
From: https://www.cnblogs.com/david-zhang-index/p/16846493.html

相关文章

  • arguments
    arguments概述:arguments是对象的一个特殊属性。arguments对象就像数组,但是它却不是数组。argument对象包含了函数调用的参数数组,通过这种方式你可以很方便的找到最后......
  • Ansible 魔法变量(magic variables)和Facts变量
    AnsibleFacts要这样玩才让人心服Ansible体系文章,IT民工金鱼哥希望能以通俗易懂、诙谐幽默的方式给大家呈现这些枯燥的知识点,让繁重的学习变的有趣一些。1.前言描述......
  • What is the difference between non local variable and global variable? Python
    Whatisthedifferencebetweennonlocalvariableandglobalvariable?回答1"nonlocal"meansthatavariableis"neitherlocalorglobal",i.e,thevariable......
  • @PathVariable注解的功能说明
    转自:​​http://www.java265.com/JavaFramework/SpringMVC/202204/2800.html​​注解的功能:   注解(Annotation),也叫元数据。一种代码级别的说明。它是JDK1.5及以后版......
  • 【spring框架】@PathVariable、@RequestParam、@RequestBody
    1.获取单个值的话,使用@PathVariable和@RequestParam,不过@PathVariable是从url中获取restful形式的数据,不会获取?后的拼接数据,而@RequestParam就是获取url?后拼接的数据。但......
  • tf中的Variable
    importtensorflowastfstate=tf.Variable(0,name='counter')#一定要定义成它是变量,它才是个变量#0就是这个变量的值,而name就是变量的名字print(state.name)#变......
  • ABC246D 2-variable Function 题解
    ABC246D2-variableFunctionSolution目录ABC246D2-variableFunctionSolution更好的阅读体验戳此进入题面SolutionCodeUPD更好的阅读体验戳此进入题面存在函数$f......
  • golang postman api(environments)
    获取所有environmentspackagemainimport("fmt""net/http""io/ioutil")funcmain(){url:="https://api.getpostman.com/environments"method:="GET"clien......
  • nested exception is java.lang.IllegalStateException: PathVariable annotation was
    本文为joshua317原创文章,转载请注明:转载自joshua317博客 https://www.joshua317.com/article/282错误显示:使用SpringBoot进行开发时,使用feign组件进行远程调用,可能会......
  • [Typescript] Tips: Assign local variables to default generic slots to dry up you
    YoucanDRYupyourgenericscodeMASSIVELY(andimproveperf)byassigninglocalvariablestodefaultgenericslots.Here,wemovesomecomplex'Extract'logi......