What's the difference between a System property and environment variable

前端 未结 2 1333
误落风尘
误落风尘 2020-12-01 04:22

I am not clear about this. When I run a java App or run an Applet in applet viewer, (in the IDE environment), System.getProperty(\"java.class.path\") gives me

相关标签:
2条回答
  • 2020-12-01 04:50
    System.getProperty("Propertname") **Platform Independent** 
    

    The above method will return JVM arguments and properties.

    System.getenv("EnvName")       **Platform Dependent**
    

    The above method returns your operating system environment variables.

    In Linux you can set a environment variable from the shell using the following command.

    export SYSTEM_TYPE=PROD
    

    In Java you can read the variable by

    System.getenv("SYSTEM_TYPE")
    

    The above code will return PROD

    http://javarevisited.blogspot.in/2012/08/how-to-get-environment-variables-in.html

    0 讨论(0)
  • 2020-12-01 05:08

    Environment variables are specific to the operating system. Properties are JVM only.

    0 讨论(0)
提交回复
热议问题