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

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