My question is a followup for the following: How to pin Eclipse to the Unity launcher?

I created Eclipse's icon to the Unity launcher based on the selected answer at the above link. However, when I launch Eclipse via this icon, the environment variables are not properly set.

I need to call . /opt/intel/bin/compilervars.sh intel64 to use Intel compiler tools in Eclipse. However, launching via the icon can't do it. Of course, running manually Eclipse on the terminal is okay.

I tried to place . /opt/intel/bin/compilervars.sh intel64 on several places such as /etc/profile and /etc/bash.bashrc. But, still not working.

Where is the best and correct place to call such environment setup?


My recommendation is to create a shell script that will run eclipse the same way that you want it to be launched (with presetting the environment variables, etc) and have the launcher icon call this script instead of Eclipse.

Your other option is to add the environment variables to the eclipse.ini file.

  • The shell script option is the WAY better option Mar 21 '12 at 7:56

I did something similar folowing answer https://askubuntu.com/a/53061/60489 and https://askubuntu.com/a/106529/60489. The result:

[Desktop Entry]
Comment=Eclipse Integrated Development Environment

the StartUpWMClass made all Eclipse's windows, appear under one launcher icon.
Eclipse.sh is a shell script that makes initializations and some temp files cleanup.


I have eclipse in /opt

sudo mv eclipse 
cd /opt/eclipse/
sudo chown -R root:root eclipse
sudo chmod -R +r eclipse

Then I make it executable from terminal.

sudo gedit /usr/bin/eclipse

Enter the following and save, change the path if you need to.

 export ECLIPSE_HOME="/opt/eclipse"
 $ECLIPSE_HOME/eclipse $*

The make that executable

 sudo chmod 755 /usr/bin/eclipse

Now make sure that you can run eclipse from terminal. (move out of /opt if you are in there, maybe just go back to home "cd ~")

If thats all working and you want a unity icon.

sudo gedit /usr/share/applications/eclipse.desktop &

[Desktop Entry]
Comment=Eclipse IDE for Java Developers

Now use the unity search for eclipse and run it. Right click it in the launcher, click "Keep in Launcher".


I had the same problem. What I did was I did vi .bashrc and added an alias with alias ecl="/home/*myUserName*/eclipse/./eclipse". Then I set the persistent environmental variable via sudo echo *VARIABLE=VALUE* /etc/environment. If you do not want to set a persistent environmental variable, you can do export VARIABLE=VALUE in the terminal window that you will be using for opening Eclipse via ecl.

Then I opened a new terminal and simply entered ecl. Eclipse would open and the recognizes the environmental variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.