简体   繁体   中英

System.getenv() call in JVM

I am setting environment variable in my machine using export MY_KEY=foo . And I am trying to fetch it in JVM using System.getenv("MY_KEY") . This returns null. But running echo $MY_KEY shows foo on the terminal.
I have tried restarting the IDE. Doesn't work, still.

The environment variable is only available to sub processes of the shell that exported it. Did you start your IDE from that shell?

If you want the variable to be available all the time, you need to add it to the /etc/profile file or create a extra file in /etc/profile.d. It depends on your operating system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM