Home >Java >javaTutorial >java gets linux environment variables

java gets linux environment variables

高洛峰
高洛峰Original
2016-12-17 13:26:413427browse

In Linux environment, how to obtain environment variables in java program?

System.getenv('Variable name')

Note: getenv is all lowercase

Some people also said to use System.getProperty(System.env('Variable name')), but I tried it but it didn't work.

My personal guess for the specific reason is that System.env() obtains system-level environment variables, which are variables under /etc/profile

Under normal circumstances, we will write the environment variables we define to the current user's configuration file, in the ~/.profile file.



For more articles related to java obtaining linux environment variables, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn