java applications a double icon appears

Bug #757991 reported by xens on 2011-04-11
174
This bug affects 37 people
Affects Status Importance Assigned to Milestone
BAMF
Low
Unassigned
Unity
Triaged
Low
Unassigned
unity-2d
Undecided
Unassigned
bamf (Ubuntu)
Undecided
Unassigned
openjdk-6 (Ubuntu)
Undecided
Unassigned
unity (Ubuntu)
Low
Unassigned

Bug Description

I have this problem with many java based programs.

I create a launcher in unity (right click: "Keep in launcher"), and when I re-launch the application a double icon of the application appears.

Step to reproduce:

1. download josm here: http://josm.openstreetmap.de/
2. open a terminal and launch the application: java -jar josm-tested.jar
3. stick the application to unity (right click: "Keep in launcher")
4. close the application
5. launch the application from the unity launcher
6. the problem should appear

Alex Launi (alexlauni) wrote :

this is because of the lack of a proper desktop file.

Changed in unity:
status: New → Confirmed
Changed in unity (Ubuntu):
status: New → Triaged
Changed in unity:
importance: Undecided → Low
status: Confirmed → Triaged
Changed in unity (Ubuntu):
importance: Undecided → Low
Changed in bamf:
status: New → Triaged
importance: Undecided → Low
xens (r-aviolat) wrote :

Maybe a picture will help to understand !

Didier Roche (didrocks) on 2011-04-13
Changed in bamf (Ubuntu):
status: New → Triaged
xens (r-aviolat) wrote :

Hi Alex,

I have a proper .desktop file, without it the program never appears into unity.

I created a new .desktop file following the steps: http://ubuntuforums.org/archive/index.php/t-499978.html
ans now it's worse, the launcher appears in unity but when I launch it the icon fade in/out for a few seconds and nothing happens.

Thanks

Romain

Norbert Klein (kleinnorbert) wrote :

The same problem appears when using the program jEdit, which is also Java based.

The problem can easily be reproduced:

1. Install jEdit from the Ubuntu Software Center
2. Click on the "Add to Launcher" button while it installs
3. Click on the newly created jEdit launcher item

Performing these steps will cause a second jEdit launcher item to show up.

A related error is that clicking the original launcher item will start a new instance of the program instead of switching to the running one. However, trying to launch a new instance from the second launcher (using shift + click or middle click) only switches to the running instance.

If the option "Keep in launcher" is selected for the second launcher item and all instances of the program are closed, it is impossible to start the program from this launcher. Although it should be kept the item will also disappear after logging out and back in.

Brandon Mayes (bdmayes) wrote :

I have noticed this exact behavior with Oracle's SQLDeveloper. If you install a program through the package manager (synaptic, apt-get, dpkg, etc.) then you can hit the super key, type the name of the program, and then select it from the list to launch it. This prevents multiple icons from appearing on my system, but isn't ideal since you still can't have a shortcut icon in the launcher.

I do notice other strange behavior with SQLDeveloper but I'm not sure if happens with all Java programs or not. Certain actions within SQLDeveloper (such as adding a new connection) cause the window borders to disappear from all windows. You can no longer see the borders, click the close/min/max buttons, or move the window (unless you hold ALT and drag the window around). The only way to fix it is to restart the X session (i.e. logout/login). This might be an entirely separate issue though?

Reinis Ivanovs (dabas) wrote :

This problem applies to NetBeans 7.0 as well. xprop shows these properties for the NetBeans window:

WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "java-lang-Thread"

However, using StartupWMClass=sun-awt-X11-XFramePeer or StartupWMClass=java-lang-Thread in a .desktop file does not help the problem.

Didier Roche (didrocks) on 2011-05-31
Changed in unity-2d:
status: New → Triaged

Same here with JabRef. Clicking on the icon on the launcher launches the program allright, but creates a second JabRef icon in the launcher (as if I had lanched the program from outside of the launcher). clicking again on the "original icon" lanches a *new* instance of JabRef (instead of going into expo mode). Clicking on the "additional icon" in the launcher does trigger the expo mode.

Various resources on the web point to the use of a customised java agent to resolve this - one that allows WM_CLASS to be modified. The idea being that if the app is launched using this agent WM_CLASS can be set the same as a StartupWMClass setting in the .desktop file and Unity will match the two strings and thus associate the running app with the correct icon.

I've tested this in GNOME Shell (shortly before the final release, so a little while ago now) and it did the trick. However, it doesn't appear to work in Unity.

Using xprop I can see that WM_CLASS is set appropriately, e.g. 'WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "DbWrench"'. This corresponds with the line 'StartupWMClass=DbWrench' in my .desktop file.

Granted, for people who tend to use only stock applications this isn't a big deal I'm sure. Three of the applications I use every day are Java apps affected by this issue though: six icons for these three is an irritation and it's even more irritating that for apps based upon the Netbeans Platform the icon displayed for the running app is different to the launcher. Not user-friendly.

Florian Boucault (fboucault) wrote :

This bug does not occur with jEdit in Unity 2d on Ubuntu Natty.

Changed in unity-2d:
status: Triaged → Invalid
Norbert Klein (kleinnorbert) wrote :

I cannot confirm that the bug doesn't occur with jEdit in Unity 2D. Using the latest Oneiric daily build with Unity 4.4.0 and Unity 2D 3.8.10 I was able to reproduce the problem following the aforementioned steps .

However, it should be noted that the bug only appears with jEdit 4.3.2 from the repository. The recently released version 4.4.1 of jEdit which can be obtained from http://sourceforge.net/projects/jedit/files/jedit/4.4.1/ includes a fix for the launcher bug. See change log at http://jedit.org/CHANGES44.txt (last bullet point under version 4.4.1).

Although jEdit works in its latest version that does not necessarily mean that other Java based programs are not affected by this bug.

Dmitry (dmitry-korolyov) wrote :

Confirmed with Intellij Idea.

Didier Roche (didrocks) on 2011-08-02
Changed in unity-2d:
status: Invalid → Triaged
Changed in unity-2d:
status: Triaged → Invalid
Didier Roche (didrocks) on 2011-10-03
Changed in unity-2d:
status: Invalid → Triaged
Changed in unity-2d:
status: Triaged → Invalid

Bug still here in Oneiric (tested with JabRef)

It is fixed in JEdit since version 4.4.1 (Oneric is still in 4.3.2)

http://jedit.svn.sourceforge.net/viewvc/jedit/jEdit/trunk/package-files/linux/deb/jedit.desktop?r1=12261&r2=19561&pathrev=19561

So it is possible to fix this by changing the .desktop file. In this case they added the following attribute

StartupWMClass=org-gjt-sp-jedit-jEdit

I have a similar problem with IntelliJ IDEA. I cannot get it to be kept in Launcher at all.

If you download and install a cross-platform Java application, not specifically packaged for Ubuntu, then you will obviously not get any .desktop file. Are you, as a user, supposed to write a .desktop file for it in order for Unity to handle it properly?

chuinker (corey-corlogic) wrote :

I was able to fix this for SQLDeveloper:

Using xprop, I found the following line

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

Based on the comments above, I added the following line to my local sqldeveloper.desktop file.

StartupWMClass=oracle-ide-boot-Launcher

Doug Morse (dm-dougmorse) wrote :

Same problem with JabRef, and I cannot seem to find a resolution.

Is there not a webpage somewhere the explains, in detail, how BAMF does it's matching?

For JabRef, xprop reports:

morse@s3 launchers> sleep 2; xprop | grep WM_CLASS
WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "net-sf-jabref-JabRefMain"

I have tried setting StartupWMClass to these two values, as well as "java-lang-Thread" in my jabref.desktop file. Nothing works, I always get a duplicate icon showing up in Unity's launcher.

For completeness, the present contents of my jabref.desktop file are:

#!/usr/bin/env xdg-open

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=java -jar /opt/jabref/JabRef.jar
StartupWMClass=net-sf-jabref-JabRefMain
Name=Jabref
Comment=Jabref Reference Manager
Icon=/opt/jabref/JabRef-icon-48.png

Doug Morse (dm-dougmorse) wrote :

Well, scratch that. With StartupWMClass still set to "net-sf-jabref-JabRefMain" in my Jabref.desktop, apparently after logging off and back on, JabRef now only shows a single icon after starting, and interaction with in the icon seems to be working fine, just as with other, non-Java apps.

So, perhaps Unity caches the contents of .desktop files somewhere (or at least those in the Launcher), on disk or in memory?

Brandon Mayes (bdmayes) wrote :

SQLDeveloper works great with this fix (adding "StartupWMClass=oracle-ide-boot-Launcher" to the .desktop file)!! Thank you so much for pointing that out!

I tried to use the same method to make iReport work but unfortunately it does not work correctly. xprop gives me the following string:

WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "java-lang-Thread"

I tried putting StartupWMClass=java-lang-Thread into my ireport.desktop file and then dragging it to the launcher. It no longer adds a second icon to the launcher, but it still does not behave correctly. The problems I see are:

1. It doesn't add the little arrow to the left of the icon to indicate that it is running.
2. If you attempt to minimize the window then it just completely hides the running application, but a quick ps -ef | grep ireport proves that the PID is still alive and well -- you just cannot access it. In order to open ireport again you have to kill the running PIDs and then start it up again.

For reasons that I cannot really change, I am still using iReport 4.0.1. I'm not sure if one of the newer releases would work or not. But essentially it looks like it's being launched as a thread in some other process (probably the NetBeans IDE, which is what it's based on). Any ideas?

For now I have configured everything in ~/.local/share/applications/ireport.desktop can therefore launch it by opening dash, typing ireport, and then selecting the item from the list. This is what I have been doing with SQLDeveloper for months, but would prefer to pin it to the launchbar if possible.

Shiba (shiba89) wrote :

It seems fixed in Precise. Can anyone confirm?

marcel (marcel-stancu) wrote :

The problem is still there for Precise (Beta2) - verified for Intellij Idea. The solution in comment #13 works.
Here are my Intellij_idea.desktop:
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/usr/lib/idea-IU-117.117/bin/idea.png
Name[en_US]=Intellij_Idea
Exec=/home/marcel/intellij-cache-ram.sh
Comment[en_US]=Java IDE editor
Name=Intellij_Idea
Comment=Java IDE editor
Icon=/usr/lib/idea-IU-117.117/bin/idea.png
Categories=Application;
StartupWMClass=jetbrains-idea

Ritesh Khadgaray (khadgaray) wrote :

a bug with java, and not unity. We need a way to set WM_CLASS in java apps.

reference:
http://elliotth.blogspot.in/2007/02/fixing-wmclass-for-your-java.html
https://bugzilla.gnome.org/show_bug.cgi?id=647437

Changed in openjdk-6 (Ubuntu):
status: New → Confirmed
Changed in bamf (Ubuntu):
status: Triaged → Invalid
Changed in bamf:
status: Triaged → Invalid
nZain (patrick-stalph) wrote :

I can confirm (that this is a pain).

1) Use xprops to find the proper WM_CLASS for your running application (e.g. downloaded jar, JabRef in my case).
2) From comment #16, add the proper tag to your desktop file: "StartupWMClass=<WM_CLASS>" (modify according to results of 1). This does not work yet. Actually, the app shows up for 1s and disappeared. Previously, without the startupwmclass tag, it was a void icon (nothing display), that did not work either. The trick is:
3) Put that desktop entry into your launcher, log out, log in.

I was able to hit the icon shortly before it disappeared, which crashed compiz *g*. Without compiz the icon did not disappear and right-click > keep in launcher worked fine. After relog, compiz works again and the icon too. Alternatively, it could work to drag&drop the desktop file to the launcher (which had no effect on my system - zero sized icon eventually?) and relog.

Stephen M. Webb (bregma) on 2013-08-06
tags: added: java-in-launcher
Changed in unity (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.