2

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?

Nullptr
  • 123

4 Answers4

5

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.

yossile
  • 5,728
1

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.

 #!/bin/sh
 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]
Version=1.0
Type=Application
Terminal=false
StartupNotify=true
Icon=/opt/eclipse/icon.xpm
Name=Eclipse
Comment=Eclipse IDE for Java Developers
Exec=eclipse
Categories=Development;

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

Andy
  • 1,563
  • 2
  • 11
  • 18
1

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

[Desktop Entry]
Type=Application
Name=Eclipse
Comment=Eclipse Integrated Development Environment
Icon=/opt/eclipse-helios-SR2/icon.xpm
Exec=/home/user/bin/Eclipse.sh
Terminal=false
Categories=Development;IDE;Java;
StartupNotify=true
StartupWMClass=Eclipse

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.

Awi
  • 688
0

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.

Amir
  • 609
  • 1
  • 9
  • 21