5

I recently installed the latest version of Eclipse that I downloaded from the Eclipse website. It is located at /opt/eclipse. I have a symbolic link form /usr/bin/eclipse to /opt/eclipse/eclipse. I also have a file named eclipse.desktop in /usr/share/applications, whose contents are as follows:

[Desktop Entry]
Name=Eclipse
Comment=Eclipse C++ IDE
Exec=/opt/eclipse/eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=Development;
StartupWMClass=Eclipse

/opt/eclipse/icon.xpm exists. However, the icon is not shown in the dock or in the list of applications. Any ideas? I'm on Ubuntu 14.04.

EDIT: Tried updating StartupWMClass, doesn't help. Here's a screenshot that captures the situation:

[enter image description here]

Jacob Vlijm
  • 83,767
SPMP
  • 165
  • This usually happens if one of the fields is invalid. What happens if you change the Exec= line into /opt/eclipse/eclipse? (or if you run from a terminal: eclipse, or /usr/bin/eclipse) – Jacob Vlijm Feb 17 '16 at 19:20
  • Changing to /opt/eclipse/eclipse doesn't fix it. I have never had a problem running eclipse with this link. The only issue is that the icon doesn't show up. – SPMP Feb 17 '16 at 20:03
  • Ah, do you mean a launcher without an icon, or no launcher at all? – Jacob Vlijm Feb 17 '16 at 20:06
  • The launcher has an icon of a sheet of paper. When eclipse is running, a question mark appears on the dock. – SPMP Feb 17 '16 at 20:23
  • When I use the Alt+Tab task switcher, icons for all other tasks show up fine, but there is nothing showing for eclipse. – SPMP Feb 17 '16 at 20:24
  • See my updated answer. I understood the generic icon appeared while running Eclipse, but you image shows it has no icon at all. – Jacob Vlijm Feb 18 '16 at 06:22

2 Answers2

3

I am pretty sure you have another eclipse.desktop file in ~/.local/share/applications. The one you show in the image looks fine. Most likely, you ran Eclipse a single time before moving it to /opt. Then a .desktop file is automatically created in ~/.local/share/applications.

.desktop files in ~/.local/share/applications overrule global ones in /usr/share/applications, which means that whatever you change to the global one, it has no effect whatsoever; the one in ~/.local/share/applications takes precedence ans is the one that shows in the Launcher.

If so, remove the one in ~/.local/share/applications, log out and back in.


EDIT


After your latest comment, it becomes clear what happened: It turns out you previously made a local launcher with alacarte. Alacarte does not handle icon paths correctly when using absolute paths; alacarte simply leaves out the icon's extension, but extensions are needed when using absolute paths.

See also here.

Jacob Vlijm
  • 83,767
  • Thanks for the answer. Doesn't help though. I've updated the question with a screenshot. – SPMP Feb 17 '16 at 21:27
  • @user2308211 See my updated answer. I understood the generic icon appeared while running Eclipse, but your image shows it has no icon at all. – Jacob Vlijm Feb 18 '16 at 06:28
  • 1
    Thanks!! Here's what was happening: There were no eclipse.desktop files, but there were quite a few alacarte-made**.desktop files from my previous attempts using the GUI launcher creator. Deleted all of those, and the icon shows up fine. – SPMP Feb 18 '16 at 20:05
  • @user2308211 perfect! One of them must have been the one in the launcher :) – Jacob Vlijm Feb 18 '16 at 20:08
  • One other concern though. I'm using the compiz application switcher, so that I can see each window (for example different Google Chrome windows) as a separate entity in Alt+Tab. Usually, the icons show up when I do Alt+Tab, but that one is still empty for Eclipse. Any ideas? – SPMP Feb 18 '16 at 20:14
  • @user2308211 did you already log out/in or restart? – Jacob Vlijm Feb 18 '16 at 20:18
  • Yeah. That's when the original problem was fixed. – SPMP Feb 18 '16 at 20:19
  • I'm pretty sure the correct desktop file is used. Because I tried changing icons, and they change correctly. – SPMP Feb 18 '16 at 20:21
  • @user2308211 I checked with a launcher pretty much the same as yours, in Unity it works fine here. Will try to find out... – Jacob Vlijm Feb 18 '16 at 20:33
  • I'm not using the unity switcher though. I think that might be the reason. I'm using compiz application switcher. I prefer each window to be an entry in the switcher. – SPMP Feb 18 '16 at 20:44
  • Ubuntu 16.04, Eclipse oxygen How to set an icon for Eclipse? works for me – charles.cc.hsu Oct 14 '17 at 07:47
3

I had the same issue which wasn't solved by any of the above but by not enclosing the path to the icon file in quotes (there were no spaces in the path or file name). Icon was then displayed as expected. The exec line handled quotes fine though.

ie changed

Icon="/path/to/file/icon.xpm"

to

Icon=/path/to/file/icon.xpm
anonymous2
  • 4,298
  • This is good information for those who have a blank icon and a .desktop file with quotes in the line as in your example as I can confirm quotes can blank the icon, however if you check the OP's post, you'll note that this is not the case for them. This information would have been more accessible and useful as a self answered Q&A. – Elder Geek Apr 19 '17 at 22:48
  • This worked for me. Thanks for solving my problem. – Pupil Sep 18 '18 at 11:47