System.getenv() call in JVM

Ashwin :

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.

Ralph Löwe :

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.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=389351&siteId=1