Home >Java >javaTutorial >java gets linux environment variables
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!