Home > Java > javaTutorial > body text

java gets linux environment variables

高洛峰
Release: 2016-12-17 13:26:41
Original
3373 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!