249

How can I pin eclipse indigo 3.7 I have 'installed' at /opt/ to the taskbar?

I have tried launching eclipse and right-clicking to choose the 'keep in launcher' option. But when I click that icon, after closing eclipse, it doesn't start eclipse.

I have already looked at How do I add Eclipse Indigo to the launcher? but no answer worked for me. (Mod note: The answers from this thread are now merged into this one)

nunos
  • 3,410
  • 6
  • 23
  • 25
  • I can start Eclipse directly from the executable in /home/USERNAME/eclipse. When I do this, the Eclipse icon on the dock has a little arrow next to it, so it is aware of Eclipse running. How strange. – csilk May 03 '12 at 20:17
  • 1
    I've had the same error, I was trying to execute eclipse_64bit on ubuntu_32bit. Have you downloaded 64bit version of Eclipse? Have you checked your ubuntu installation? –  May 07 '12 at 20:54
  • i think you dont need the /bin/sh part in the Exec section. Remove it and it should work. By the way, what is your username? – Salem Aug 07 '12 at 12:38
  • I had the same problem with Eclipse 4.5.2 and Ubuntu 14.04 - accepted answer worked. – Gustave May 11 '16 at 05:31

16 Answers16

354

For 11.10 and newer

First, create a .desktop file to eclipse:

gedit ~/.local/share/applications/opt_eclipse.desktop

Then, paste this inside (dont forget to edit Exec and Icon values):

[Desktop Entry]
Type=Application
Name=Eclipse
Comment=Eclipse Integrated Development Environment
Icon=** something like /opt/eclipse/icon.xpm **
Exec= ** something like /opt/eclipse/eclipse **
Terminal=false
Categories=Development;IDE;Java;
StartupWMClass=Eclipse

After that, open that folder with nautilus:

nautilus ~/.local/share/applications

If you want to use this launcher outside dash/launcher (ex: as a desktop launcher) you need to add execution permission by right clicking the file and choosing Properties -> Permissions -> Allow execution, or, via the command-line:

chmod +x ~/.local/share/applications/opt_eclipse.desktop

Finally drop opt_eclipse.desktop to launcher.

Salem
  • 19,744
  • 1
    Is it really necessary to create the .desktop file outside user's home folder? As you can see, this requires sudo, which is potentially unsafe; also, the file may be removed by a system upgrade or reinstall. What are the benefits? – Sergey Nov 16 '11 at 23:50
  • No, you can create the file where you want. I suggested this location because it's the folder where usually .desktop files are stored (so it is "found" by applications like unity, gnome do, etc). The name is unfortunate, because it's the same of the .desktop file created by eclipse package, when installed by Software Manager. I'll change it. – Salem Nov 17 '11 at 00:09
  • 19
    ~/.local/share/applications is probably where you want to put it. – Jorge Castro Nov 17 '11 at 04:15
  • What do you mean by "drop ... to dash"? – Catskul Dec 29 '11 at 20:46
  • 1
    @Catskul i meant the launcher. – Salem Jan 02 '12 at 15:09
  • 1
    I also had to append StartupWMClass=eclipse at the end of the .desktop file, or else Unity was unable to detect if an instance was already running or not (thus trying to re-launch eclipse each time, and failing due to locks on the workspace) – alci Mar 08 '12 at 09:29
  • /usr/local/share/applications should also work if you want a global installation. – detly Mar 12 '12 at 08:00
  • @Salem Ok, this is late but you don't need the desktop file to have executable permission "On". Just leave it as it is, drag to the launcher and it will execute whatever you placed in the exec part of the .desktop file. – Marky Dec 13 '12 at 04:02
  • @Marky yes that's true. That was added by others and i let it stay because it doesn't hurt, and if you don't add the execution permission, you can't launch it in Nautilus (double-click) neither is shown the icon defined in "Icon". – Salem Dec 13 '12 at 20:27
  • @alci For me it was StartupWMClass=Eclipse, didn't work lowercase. – ubuntudroid May 14 '13 at 19:56
  • 1
    OK. I know this probably WORKS. But, why the hell is it necessary? I just want to start my app, right click the launcher icon that appears and have Ubuntu fix things for me. I challenge thee oh fine Ubuntu developers, make it so! – Mr. Developerdude Oct 01 '13 at 10:40
  • For me it only works when I start it directly from nautilus. When I drop the icon to the launcher and start it from there, it won't work. – user1170330 Nov 20 '13 at 17:41
  • @LennartRolland It only broke for me after I moved the location of Eclipse folder after pinning it. In 14.04 the posted solution worked to fix it. – Steve M Sep 02 '14 at 19:44
  • 8
    Do we seriously need to edit a 10-line file and run some file permissions command to create an app shortcut in 2014? – Dan Dascalescu Nov 07 '14 at 20:44
  • +1 this explanation is awesome. I used it to pin Visual Studio Code to the launcher (StartupWMClass=Code worked). – ashes999 Jun 17 '15 at 18:53
  • @DanDascalescu uhh yeah? That's the way Linux works... – Tim Oct 30 '15 at 12:22
  • 1
    @Tim: by that logic we should always pay in cash, because that's how money works. – Dan Dascalescu Nov 01 '15 at 21:51
  • @DanDascalescu Well the main reason is for security - I don't want a downloaded file running itself (or similar)... – Tim Nov 01 '15 at 21:53
  • 2
    @Tim: what does the lack of simple UX for creating a shortcut have to do with security? Both Mac OS and Windows do a great job of making it easy to create shortcuts. Ubuntu does not. – Dan Dascalescu Nov 03 '15 at 04:20
  • If you already told to 'keep in launcher' eclipse, there will be a file eclipse.desktop in /usr/local/share/applications (thanks to detly). Just edit the path and exec and you need not to copy/add/drop/... anything else :) – BurninLeo Nov 28 '15 at 11:50
  • 3
    This answer 5 years old, and the only one that still works in 2016. Of course, Ubuntu could just upgrade the version of Eclipse on the software center so people would not have to do manual installs that break the shortcut generation process. – Dominic Cerisano May 16 '16 at 20:31
  • FWIW with 16.04 and Eclipse Mars (newer than the software center version) I didn't need to jump through any hoops - I just chose "Add to dash" and "Lock to launcher" when eclipse was open and that locked icon worked to launch eclipse. I'm not sure if Unity changed, or eclipse did... – BeeOnRope Nov 04 '16 at 17:38
  • I tried this on Ubuntu 18.04 but upon double-clicking on the file, it says The Eclipse executable launcher was unable to locate its companion shared library! How can I fix this error? – Milan May 24 '21 at 13:48
  • This works on 20.04 – dario_ramos Jul 05 '22 at 04:49
90

For Ubuntu 11.10, 12.04, 12.10

If the applications folder does not exist inside ~/.local/share/ create it

mkdir ~/.local/share/applications

Check if your installation left you with a workable .desktop file for Eclipse and copy it if exists

cp /usr/share/applications/eclipse.desktop ~/.local/share/applications/

If the file does not exist create a .desktop file for Eclipse in your ~/.local/share/applications/ folder using gnome-desktop-item-edit, ie:

gnome-desktop-item-edit --create-new ~/.local/share/applications/

On the name set it to Eclipse, on the command enter the path to the binary file of Eclipse, insert a comment if you want and click the icon to select the icon that you desire for Eclipse.

Press ok when you are finished.


After copying the file or creating your own open that folder location

nautilus ~/.local/share/applications/

Locate the file you just created and drag it to the launcher

enter image description here

Bruno Pereira
  • 73,643
18

11.04

If user21580's answer doesn't work (great suggestion, but I think it didn't work for me when I installed Indigo), you can try adding an eclipse.desktop file to ~/.local/share/applications/, with these contents:

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
StartupNotify=true
Icon=<path-to-eclipse-install>/icon.xpm
Name=Eclipse Indigo 3.7
#Exec=env UBUNTU_MENUPROXY=0 <path-to-eclipse-install>/eclipse
Exec=env <path-to-eclipse-install>/eclipse

If you experience bugs, you can try the Exec line which is commented out instead of the current one.

References:

Christoph
  • 3,108
  • Thanks! This one worked for me. Too bad Ubuntu has to make it so difficult. Why not just right click on the launcher for this kind of option? – Twisted Pear Feb 19 '12 at 23:11
12

Let me show you how to create a custom launcher and pin it to the Launcher.

1) First, install gnome-panel:

sudo apt-get install --no-install-recommends gnome-panel

2) To create a new desktop shortcut run the following command either in the terminal or using Alt-F2:

gnome-desktop-item-edit --create-new ~/Desktop

A window will pop up, submit your shortcut details and click OK:

enter image description here

Your shortcut will now appear on your desktop.

Then drag your new shortcut from Desktop to your Launcher.

That's it!

fouric
  • 4,588
Atem18
  • 1,563
  • 1
    I think `gnome-desktop-item-edit' needs a certain package? – gontadu Apr 07 '12 at 10:49
  • @Eshwar 'sudo apt-get install --no-install-recommends gnome-panel' –  Nov 11 '12 at 21:50
  • 1
    This doesn't pick up the icon of the app, and when dragged into the Unity task bar, it spawns yet another icon for the app. Don't mean to troll, but the experience of creating a shortcut in OS X or Windows is way, way better. – Dan Dascalescu Nov 07 '14 at 20:48
  • Click the spring icon in the window to change it to what you want. –  Apr 29 '16 at 12:00
  • 1
    Doesn't work for me in Ubuntu Desktop 16.04 LTS for Eclipse MARs...getting error at the time of launch... – Ashu May 21 '16 at 17:40
  • In 16.04 for eclipse Mars, I didn't need to jump through any hoops - I just chose "Add to dash" and "Lock to launcher" when eclipse was open and that locked icon worked to launch eclipse. – BeeOnRope Nov 04 '16 at 17:37
4

If you have donwloaded Eclipse from the website instead of install it from repositories you can lock the launcher doesn't work. You can solve this by writting the file with extension .desktop, in our case eclipse.desktop.

 [Desktop Entry]
 Name=Eclipse
 Comment=Eclipse
 Exec=/path/eclipse
 Icon=/path/icon.xpm
 Terminal=false
 Type=Application

Where /path is where you've installed eclipse. After you have saved it, you have to give execution permission:

$ chmod +x eclipse.desktop

Then you execute it with Nautilus and by clicking (right click) over the laucher you can lock to the launcher. And you can launch the app correctly.

Joe
  • 919
2

18.04

Click Show Applications, find Eclipse in the list, right click & Add to Favourites.

Chai T. Rex
  • 5,193
Phil
  • 300
  • 2
  • 7
  • 2
    Technically speaking, there is no Unity in 18.04. However, the instruction for the new default desktop (GNOME) is probably OK to be posted here. – Melebius May 03 '18 at 07:30
  • Whatever the launcher is in 18.04, it looks the same as what was in 16.04 and 14.04. I don't overly care what it is called. – Phil May 07 '18 at 00:17
2

I think this is a cleaner version:

[Desktop Entry]
Type=Application
Name=Eclipse
Comment=Eclipse Integrated Development Environment
Icon=eclipse
Exec=eclipse
Terminal=false
Categories=Development;IDE;Java;

You should add this to /usr/local/share/applications/eclipse.desktop and symlink eclipse on /usr/bin. You might want to change the icon path if your theme doesn't have a eclipse button (ex. ambiance/radiance).

If I'm not mistaken this is the file that comes with galileo from the repos (wich I removed), and I've been using it with Helios and now Indigo.

sergio91pt
  • 2,942
1

For 12.04
I prefer to install from repository. This just works for me and I document the Graphical way to do it here.

If you must install the portable version(getting the tar.gz from the eclipse website) here's the best way I've found to get portable working and locked to the Launcher.

Download the eclipse portable and extract to your Desktop. In a terminal:

sudo apt-get install eclipse-platform
sudo mv Desktop/eclipse /opt/eclipse
/opt/eclipse/eclipse

Right click the icon in the launcher bar and pin to bar. I can verify that it's portable and not the platform because I have LOADS of plug-ins installed which don't appear when launched this way.

You may find that creating a .desktop file works, but that you run into mysterious behaviour if you have more than one portable instance installed.

RobotHumans
  • 29,530
1

Try

Exec=/bin/bash /home/USERNAME/eclipse/eclipse

or make /home/USERNAME/eclipse/eclipse executable

sudo chmod u+x /home/USERNAME/eclipse/eclipse

and use:

Exec=/home/USERNAME/eclipse/eclipse
Binsh
  • 51
  • It's already executable and your other suggestion of changing sh to bash made no difference. – csilk May 03 '12 at 21:33
1

Make sure if you're using the 32bit version on a 64bit machine, you install the 32bit libraries (ia32libs-multiarch i think is the package in Precise).

Alternatively, if you're trying to run 64bit Eclipse on a 32bit machine, you need to download the 32bit version instead.

Thomas Ward
  • 74,764
1

I have tested it for Eclipse MARs(not the installation one)-but the one which is tar.gz package on Ubuntu Desktop 14.0.4

gedit /usr/share/applications/eclipse.desktop

contents for this:

[Desktop Entry]
Type=Application
Name=Eclipse
Comment=Eclipse Integrated Development Environment
Icon=** something like /opt/eclipse/icon.xpm **
Exec= ** something like /opt/eclipse/eclipse **
Terminal=false
Categories=Development;IDE;Java;
StartupWMClass=Eclipse

Then in the finder search for Eclipse when the menu comes up - just drag it to the launcher and then it will start working. Very simple steps and nothing complicated to get it up and running.

Ashu
  • 3,966
0

For Ubuntu 11.10

Download gnome-panel from the Ubuntu Software Center if not already installed.

Run the Gnome "Create Launcher" from the terminal like so:

gnome-desktop-item-edit --create-new ~/.local/share/applications/

A dialog box will appear.

  • For Name: you'll probably want to name it "Eclipse".
  • For Command: browse to where the Eclipse executable is located.
  • For Comment: something like "Eclipse IDE" should do.
  • For the icon, click the springboard icon, then navigate to the folder where the executable is located and select icon.xpm.
  • Click Okay. You've now made the launcher icon. All that's left is to put it in the launcher bar.
  • Open the folder ~/.local/share/applications/ . You may need to hit ctrl-h to show the hidden .local folder.
  • Drag the Eclipse launcher icon you just made onto the launcher.

Done!

0

In the exec line put the executable (eclipse) directly. Don't try to add special characters to space, i.e., if your eclipse is in the /home/username/My Dev Programs/Eclipse/eclipse put the entire line with the spaces on the exec line. Here is a my eclipse.desktop file:

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon=/home/marcos/Imagens/Icons/Eclipse Icon 128.png
Name=Eclipse
Exec=/home/marcos/Dev Software/eclipse/eclipse
Comment=Eclipse IDE
Name=Eclipse
Comment=Eclipse IDE
  • If you look at my config you can see that I am not doing anything with special characters or spaces. – csilk Jun 22 '12 at 14:07
0

Use this:

[Desktop Entry]
Version=4.2
Name=Eclipse
Comment=Java IDE
Exec=/home/USERNAME/eclipse/eclipse
Type=Application
Icon=/home/USERNAME/eclipse/icon.png
Terminal=false
NoDisplay=false
Categories=Development;IDE

It works for me.

0

If not using a *.deb file, your software is not included in menus or the launcher. The easy way: Just start Eclipse from /opt and look for an icon appear in Unity launcher (the sidebar). Right click and check "Keep in launcher".

0

Atem18 is correct. Do this if you want your launchers to be available system wide. This is how I automated creating launchers. This assumes you have already installed gnome-panel.

  1. open terminal
  2. mkdir ~/bin or right click on your home file browser and make folder bin.
  3. source .profile or logout and login
  4. gedit in terminal or from dash

    #!/bin/sh 
    sudo gnome-desktop-item-edit /usr/share/applications/ --create-new
    

    Don't use the hyphens/bullets and no need to indent.

  5. Give it a name with no spaces save to your new bin directory and then make executable (chmod a+x launcher-script) or right click goto properties> Permissions and click the execute box.

  6. now in terminal: sudo gnome-desktop-item-edit /usr/share/applications/ --create-new

  7. You should have the Create Launcher gui open.

    Type = Application in Terminal THIS ONLY APPLIES THIS TIME. Most of the time it will be Application after this.

  8. You can name what you wish. NO-SPACES-ALLOWED I called mine Create-Launcher

  9. In the command field put the path to the script from step 3: /home/mike/bin/launcher-script Use your user name and the actual file name you created.

  10. Click the spring to add an icon. I made on on the Gimp but there are lots of icons you could use that are very generic and already installed. Click the spring and it will take you to some.

  11. Once you're finished click ok. Now you can navigate your file browser down to /usr/share/applications and you will find your new launcher. Simply drag it to your launcher bar and you are ready to go. This process puts your launchers in a place where all users can access them. Most of what I have found puts thing on the desktop which might be fine for some but not for me. I hope you find this helpful.

Now you can easily create your eclipse launcher and any others too.

After thought, every time you create a new launcher you will have to enter your password. This is necessary to make the new launcher accessible to all users. It will belong to root and the group will be root this way. That is the way the rest of the system comes configured. If you cd to /usr/share/applications, type ls -l and, verify for yourself. Ubuntu should have supplied their os with an application already installed for creating launchers. There are other things I disagree with like the screensaver and no short cut to the desktop. I have only been on 11.10 for a couple days. I am going to give it the college try. If I still don't like it in a month I will fix it then.

muru
  • 197,895
  • 55
  • 485
  • 740