For those looking for a solution for their Java applications in Ubuntu and other Linuxes. There seems to be 2 ways to do this, depending on what UI toolkit you use.
For those who use AWT and/or Swing (which in turn is based on AWT), you have only a workaround for now. http://elliotth.blogspot.com/2007/02/fixing-wmclass-for-your-java.html - this guy managed to fix the WM_CLASS:
Toolkit xToolkit = Toolkit.getDefaultToolkit(); java.lang.reflect.Field awtAppClassNameField = xToolkit.getClass().getDeclaredField("awtAppClassName"); awtAppClassNameField.setAccessible(true); awtAppClassNameField.set(xToolkit, "MyAppName");
For those who use SWT, there is a simpler, documented way:
Display.setAppName("MyAppName");
After you've done (1) or (2), you can now test this by running
xprop|grep WM_CLASS
It will change your cursor to be a cross sign. With the new cross-sign cursor click on the window of your running application and make sure that the output is
WM_CLASS(STRING) = "MyAppName", "MyAppName"
where "MyAppName" is the string you've passed to AWT/SWT earlier.
If everything goes fine, then add a line to the MyAppName.desktop file like the following:
StartupWMClass=MyAppName