28

I installed the latest version of Eclipse onto Ubuntu 18.04 with the official installer from the Eclipse website, however I can't get it to appear on my favorites bar/dock.

I have tried dragging the executable file to the dock, but it doesn't work.

I can't find it with the "show applications" button. I can only run it by clicking on its executable file.

How can I get Eclipse to appear on the favorites bar/dock?

The .desktop file:

[Desktop Entry]
Comment=Eclipse
Terminal=false
Name=Eclipse
Exec=eclipse --profile-directory=/home/myName/eclipse/java-2018-09/eclipse
Type=Application
Icon=eclipse

This isn't a duplicate of this question because the same process doesn't work. Changing the text file to an executable doesn't work.

2 Answers2

44

I merged this answer, OP's answer, below comments and my own experience:

  1. Create a file called Eclipse.desktop in ~/.local/share/applications (e.g. with the command nano ~/.local/share/applications/Eclipse.desktop)

  2. Add these lines:

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

    Note that 'Exec' should point to your eclipse executable, not the containing folder which is also named 'eclipse' usually. Check if the icon file is present and if necessary adapt its path. Save the file.

  3. Make the file executable by running chmod a+x ~/.local/share/applications/Eclipse.desktop.

  4. Click on 'Show Applications' (the dot logo on the bottom left of the screen) and in the search bar enter 'Eclipse'. It should appear.

  5. Right click on the Icon and choose 'Add to favorites'.

There is a lot more you can specify in a .desktop file with further key-value pairs, more info here.

smcs
  • 1,032
  • 4
    Thanks- this helped me as well but a couple of things. You don't need (and you shouldn't use) sudo to create the .desktop and make it executable. To make .desktop executable by everyone I think the right command is chmod a+x ~/.local/share/applications/.desktop. – dariober Feb 23 '19 at 11:11
  • 4
    Doing as explained above, I got a new icon in the dock for each Eclipse instance I run. Solved by adding StartupWMClass=Eclipse to the .desktop file https://askubuntu.com/a/635839/741521 – alostale Aug 06 '19 at 11:50
  • @alostale Very nice, I had the same issue and added your solution to the answer. – smcs Aug 06 '19 at 12:28
  • 2
    it is better to use program_name.desktop so if there is another program that you want to add to favorites, you can create another .desktop file ex: second_program.desktop – hossein hayati Jan 06 '20 at 07:16
  • @hosseinhayati How is it better to have multiple files rather than one file with multiple entries? Matter of taste, no? – smcs Jan 06 '20 at 09:52
  • I have seen many posts suggesting the use of this procedure and I have never been able to get it to work. Any ideas on how to troubleshoot the situation. – Jonathan May 11 '20 at 18:45
  • @hosseinhayati It seems that I was wrong about this and you need to create a file for each new application. Apologies. – smcs Jun 15 '20 at 09:56
1

First the problem with the .desktop launcher was fixed by changing the Exec line to

Exec=/home/myName/eclipse/java-2018-09/eclipse/eclipse

Then "added to favorites" following this.

pomsky
  • 68,507