How can I remove duplicate icons for "launched" java programs in the launcher?

When launching java programs (like IntelliJ IDEA and Crashplan) in Natty's Unity launcher, duplicate icons are shown (see image). For IntelliJ I created the .desktop file, for Crashplan the .desktop file is supplied with the application. Is there something that can be changed in the .desktop files (or somewhere else) that can prevent this from occurring? I couldn't find a bug report for unity itself but programs like Gnome-Do/Docky have bug reports and had to make internal changes to their applications to prevent this.

Duplicate Icons In this image the 1st icon is the one created from the .desktop file and the second icon is after launching it. Second icon disappears when closing the application.

Custom IntelliJ .desktop file

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/opt/idea/bin/idea128.png
Name[en_US]=IntelliJ IDEA
Exec=/opt/idea/bin/idea.sh
Name=IntelliJ IDEA
Icon=/opt/idea/bin/idea128.png
StartupNotify=true

Crashplan provide .desktop file

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=CrashPlan
Categories=;
Comment=CrashPlan Desktop UI
Comment[en_CA]=CrashPlan Desktop UI
Exec=/usr/local/crashplan/bin/CrashPlanDesktop
Icon=/usr/local/crashplan/skin/icon_app_64x64.png
Hidden=false
Terminal=false
Type=Application
GenericName[en_CA]=

Add a StartupWMClass string into your .desktop file. Use xprop command to get this class. For example :

$ xprop|grep WM_CLASS
 WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "java-lang-Thread"

$ cat /usr/share/applications/PHPStorm.desktop | grep StartupWM
StartupWMClass=sun-awt-X11-XFramePeer

More deatils in this thread (this about AWN, but works for Unity too)


For Intellij Idea 11 under Ubuntu 11.10 is necessary to add at the idea's .desktop file following line:

StartupWMClass=jetbrains-idea

I was able to fix this for SQLDeveloper, which is a java program:

Using xprop (and then clicking on the SQLDeveloper window), I found the following line of output:

WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "oracle-ide-boot-Launcher"

Based on the comments found above and in https://bugs.launchpad.net/unity/+bug/757991, I added the following line to my local sqldeveloper.desktop file:

StartupWMClass=oracle-ide-boot-Launcher

I've documented the fix for Eclipse 4.x and 3.x here.

This solution is for glx-dock aka Cairo-dock but works for all task bars relying on WM_CLASS.

In the case of eclipse, the launch is a two step process as well.

        enter image description here

Basically, what you need to do is to identify Eclipse branding plugin.xml applicable to your Eclipse version and modify the application name property. When the workbench main windows is created, Jface will call the SWT Display.setName and this will set you WM_CLASS. If this is the declared WM_CLASS for your launcher, then running instances will find their dock launcher.

Don't forget to do eclipse -clean on the first time.

Tabbing through is also much improved.

enter image description here