Sunday, October 21, 2012

Ubuntu: How to add Eclipse to the Unity Launcher

A quick how to: Add Eclipse to the Unity Launcher. You can add any other application to the Unity Launcher using these steps.

All the Unity Launchers (e.g. evince, gedit, etc) are implemented as .desktop files. These files are stored in the folder /usr/share/applications/. The .desktop file contains the following information: where the icon is located, where the executable is located, the launcher name, and other secondary information like a comment about the launcher.

Make Eclipse accessible from the command line


All the commands accessible from the command line are stored in a "bin" folder. The folder destined to user binaries is located in /usr/bin.

Let's add the eclipse executable to /usr/bin using the following command.

sudo ln -s /path/to/eclipse/eclipse /usr/bin/

Now eclipse is accessible from the command line as the command eclipse.

Put the icon in the right place


All the icons associated to a Unity Launcher are stored in the /usr/share/pixmap folder. Let's place the eclipse icon in the right folder.

sudo cp /path/to/eclipse/icon.xpm /usr/share/pixmap/eclipse.xpm

Create the .desktop file


Finally, you'll need to create a new .desktop file for Eclipse. Proceed with the following command.

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

Insert the following text inside this new file.

Note 1: If you didn't add eclipse to /usr/bin, you'll have to use the full path in the Exec section, e.g. Exec=/path/to/eclipse/eclipse

Note 2: If you didn't place the eclipse icon under the /usr/share/pixmap folder, you'll have to use the full path in the Icon section, e.g. Icon=/path/to/eclipse/icon.xpm

This is the result.

Now, Eclipse is accessible from dash and the Unity Launcher.

11 comments:

  1. Oh!! the best way :D :okey: I never add the eclipse to usr/bin....

    ReplyDelete
  2. Thanks :) worked for me

    ReplyDelete
  3. Worked to me too... thank you...

    ReplyDelete
  4. hei... that's work for me too. thanks :D

    ReplyDelete
  5. Thank you, that works for me on Ubuntu 13.04

    ReplyDelete
  6. This doesn't work under Ubuntu 13.04 64-bit. It puts an Eclipse icon on the launcher that doesn't launch the application (after launching eclipse from the command line and locking the icon to the taskbar). The icon shows up as Untitled window.

    ReplyDelete
  7. Here's how to make this work under Ubuntu 13.04.

    Copy the icon.xpm to /usr/share/pixmaps, not /usr/share/pixmap.

    Create the eclipse.desktop file in ~/Desktop, not /usr/share/applications.

    Make ~/Desktop/eclipse.desktop executable.

    This will put the Eclipse icon on your desktop and when you launch it you can lock it to the taskbar and the taskbar icon will launch eclipse.

    ReplyDelete
  8. +1. Brilliant. Worked for Ubuntu 12.04 64-bit.

    ReplyDelete
  9. so simple... and works! thanks

    ReplyDelete
  10. I have a issue after doing this. Eclipse menus doesn't show up, I changed the exec line of the .desktop file to

    Exec=env UBUNTU_MENUPROXY=0 eclipse

    to more information http://stackoverflow.com/questions/19452390/eclipse-menus-dont-show-up-after-upgrading-to-ubuntu-13-10

    thanks.

    ReplyDelete