2

In .bash_profile I have listed many env variables as follows:

export JAVA_HOME=...
export PYTHON=... 
...

System.getenv() returns a list of env variables (e.g., SHELL, TMP_DIR) but not those listed in .bash_profile. Where these are coming from and how to get the ones in .bash_profile?

Thanks!

2 Answers 2

3

Eclipse takes them from the run configuration. menu Run->Run Configurations...

Select your app, switch to the arguments tab, and put your env variables down there, eg:

-Dname=value

Sign up to request clarification or add additional context in comments.

2 Comments

Wait a sec! That's System.getProperties(), not getenv(). Doh.
Adding the env under configuration worked. Thanks! Would be nice to do it programmatically too. Just tried System.getProperties() and it returns a lot of stuff but not the env listed in .bash_profile
1

You probably want them in .bashrc instead of .bash_profile. See the INVOCATION section of the bash man page for details of how and when certain init files are loaded.

3 Comments

Oh, that assumes that you're running eclipse from the bash session where you've exported the variables. If running from the desktop, you'll either have to create a custom script that exports them for you or else put the variables in /etc/environment, where you don't export them, just list them like "JAVA_HOME=...".
That's exactly what I ran into when I tried to create a quick launch icon in the tool bar on Linux, and writing a simple script to start Eclipse was the solution.
Oops, on MAC, it should be /etc/launchd.conf or ~/.launchd.conf instead of /etc/environment. For example: digitaledgesw.com/node/31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.