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

天涯浪子 提交于 2019-11-27 07:24:59

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!