Environment variables in Eclipse
The .bashrc file is used for setting variables used by interactive login shells. If you want those environment variables available in Eclipse you need to put them in /etc/environment.
How to set environment variables for Java
I suspect that the environment variable you're setting in your .bash_profile
isn't getting picked up.
If you're running from Eclipse, you need to set environment variables manually on the Environment tab in the Run Configuration.
Go to Run
-> Run Configurations...
, find or create the run configuration for your app under Java Applications
, go to the Environment
tab and add your desired environment variables there.
Click the Run
button and your program should print the environment variable as expected.
Setting environment variables for an entire project
What I usually do for a global environment variable is usually set it at the OS level. I do not know if there is a way in Eclipse to set global environment variables.
Setting environment variables on eclipse
You could have the .app call an executable loader script, which can set environment variables and call the executable binary. The script is placed in Contents/MacOS/. If you swap names with the main exec. binary, Info.plist will already point to it, then call the renamed binary from the loader script.
#!/usr/bin/env bash
cd "$(dirname "$0")" || exit 1
cwd="$(pwd)"
export VARIABLE=808
exec "${cwd}/myapp"
Setting Environment variables for Eclipse IDE launching
So that Eclipse will know where Java is.
JAVA_HOME is not used by Java itself. Some third-party
programs (for example Apache Tomcat) expect one of these environment
variables to be set to the installation directory of the JDK or JRE.
If you are not using software that requires them, you do not need to
set JAVA_HOME and JRE_HOME.CLASSPATH is an environment variable which contains a list of
directories and / or JAR files, which Java will look through when it
searches for Java classes to load. You do not normally need to set the
CLASSPATH environment variable. Instead of using this environment
variable, you can use the -cp or -classpath option on the command line
when using the javac and java commands.PATH is an environment variable used by the operating system (Windows,
Mac OS X, Linux) where it will look for native executable programs to
run. You should add the bin subdirectory of your JDK installation
directory to the PATH, so that you can use the javac and java commands
and other JDK tools in a command prompt window. The JDK installation
instructions explain how to set PATH.
Source
Eclipse F3 points to old Environment Variable location
There are a couple of issues here:
Eclipse reads system environment variables at startup. You need to re-start Eclipse after any changes to environment variables.
CDT has an option to re-index your projects. See this answer.
Related Topics
Passing Function as a Parameter in Java
How to Delete Files Programmatically on Android
Is Dalvik's Memory Model the Same as Java'S
Method Called After Release() Exception Unable to Resume with Android Camera
Libavcodec.So: Has Text Relocations
How to Transform Currenttimemillis to a Readable Date Format
Preload Multiple Images with Glide
Using Httpclient and Httppost in Android with Post Parameters
How to Move/Rename File from Internal App Storage to External Storage on Android
Android "Single Top" Launch Mode and Onnewintent Method
Execute Managebean Method from JavaScript Onload Event
Calling a Java Servlet from JavaScript
Call External JavaScript Functions from Java Code