Accepted answer

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.


for the people who want to override the environment variable of os in eclipse project, refer to @max answer too.

it's useful when you have release project end eclipse project at the same machine.

the release project can use the os environment variable for test usage and eclipse project can override it for development usage.


i was able to set the env. variables by sourcing (source command inside the shell (ksh) scirpt) the file that was settign them. then i called the .ksh script from the external tools


i was trying to achieve this but in the context of a maven build. as part of my pom.xml configuration, i had a reference to an environment variable as part of a path to a local jar:

  <groupid>the group id</groupid>
  <artifactid>the artifact id</artifactid>
  <version>the version</version>

to compile my project, i had to define the environment variable as part of the run configuration for the maven build as explained by max's answer. i was able to launch the maven compilation and the project would compile just fine.

however, as this environment variable involves some dependencies, the default "problems" view of eclipse (where compilation errors/warnings usually show) would still show errors along the lines of could not find artifact and systempath should be an absolute path but is ${env.my_env_variable}/the_local_jar_archive.jar.

how i fixed it

go into window -> preferences -> general -> worksapce -> linked resources and define a new path variable.

image capture of the eclipse preferences window

finally, in my case i just needed to right click on my pom.xml file, select maven -> update project and the errors disappeared from the "problems" view.


you can also start eclipse within a shell.

you export the enronment, before calling eclipse.

example :

export my_var="adca"
export path="/home/lala/bin;$path"
$eclipse_home/eclipse -data $your_work_space_path

then you can have multiple instances on eclipse with their own custome environment including workspace.


you can set the hadoop home directory by sending a -dhadoop.home.dir to the vm. to send this parameters to all your application that you execute inside eclipse, you can set them in window->preferences->java->installed jres-> (select your jre installation) -> edit.. -> (set the value in the "default vm arguments:" textbox). you can replace ${hadoop_home} with the path to your hadoop installation.

select the jre you use for running programs in eclipse

sending the value for hadoop.home.dir property as a vm argument


i've created an eclipse plugin for this, because i had the same problem. feel free to download it and contribute to it.

it's still in early development, but it does its job already for me.

enter image description here


you can also define an environment variable that is visible only within eclipse.

go to run -> run configurations... and select tab "environment".

enter image description here

there you can add several environment variables that will be specific to your application.

Related Query

More Query from same tag