3

I recently upgraded to Eclipse Luna and since then I've had trouble launching it from the Unity Launcher. I've modified my old .desktop file located in ~/.local/share/applications, then added it to my launcher and now it looks like this:

Valid XHTML


How can I fix this?

For reference, here's my eclipse.desktop file:

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Path=/home/jinkim/eclipse
Icon=/home/jinkim/eclipse/icon.xpm
Exec=/home/jinkim/eclipse/eclipse
Name=Eclipse Luna
Comment=This is an IDE
Icon=eclipse
frog
  • 18
Jin
  • 183
  • 1
  • 8
  • slightly different symptom, same cause. – Jacob Vlijm Sep 22 '14 at 19:14
  • It's a slightly different problem, as I have already done grep -rI "eclipse" in /usr/share/applications and it turns up with nothing. The only eclipse-related .desktop file I can see is the one in my ~/.local directory – Jin Sep 22 '14 at 19:19
  • You really must have two, calling the same application, but differently named. I'll take a look... – Jacob Vlijm Sep 22 '14 at 19:21
  • Could you grep -rI "eclipse" in ~/.local/share/applications? it is possible that files have slightly different names. – Jacob Vlijm Sep 22 '14 at 19:32
  • Yes I tried the grep in ~/.local/share/applications and it turned up with the desktop file noted above. However, after searching for solutions I managed to get a working .desktop file. I will answer this question with what worked for me. Thanks! – Jin Sep 22 '14 at 20:20

3 Answers3

4

It seems there a line in the .desktop file that I was missing. In particular, the crucial line seems to be:

StartupWMClass=Eclipse

More info on that here: What represent the StartupWMClass field of a .desktop file?

So, I have found what works for me below:

#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Eclipse
GenericName=Eclipse Java IDE
Comment=Eclipse Java IDE
Categories=Utility;Developer Tools;IDEs;Java;
Exec=/home/(your-username-here)/eclipse/eclipse
Icon=/home/(your-username-here)/eclipse/icon.xpm
StartupWMClass=Eclipse
StartupNotify=true
Terminal=false
Type=Application
X-GNOME-FullName=Eclipse Java IDE

The steps I took to get this working are:

  1. Use a text editor to create eclipse.desktop, and paste the above into it

  2. Move eclipse.desktop into ~/.local/share/applications

  3. Allow it to be executable: chmod +x eclipse.desktop

  4. Double-click eclipse.desktop which should appear in Nautilus as Eclipse

  5. In Unity launcher, right-click and select "Lock to Launcher"

Jin
  • 183
  • 1
  • 8
  • The weird thing is that you had two (correct eclipse) icons. Usually in these cases one of them is apppearing as a question mark, that's why the StartupWMClass -thought didn't come into my mind. – Jacob Vlijm Sep 23 '14 at 06:48
0

Depending on how you installed Eclipse and which distribution you chose, you may find the StartupWMClass needs a different value (Use the xprop WM_CLASS method described in the link in Jin's answer above).

Having built a custom Eclipse from the Platform Runtime distribution, I was getting an extra "No Entry" icon with "SWT" as its caption. Using xprop WM_CLASS told me the class is called "SWT", and setting StartupWMClass=SWT resolves the problem.

0

I had this same problem of duplicated icon. but in my case it was caused because I double clicked in the eclipse executable and ask unit to lock it in the launcher. this action makes unity to create an eclipse.desktop file into ~/.local/share/applications where its "exec=" was set to java instead of eclipse executable. After I removed the one created by unity and added my own, the problem was solved.

Cristiano
  • 217