2

I have a Java application that I installed via install4j. The desktop shortcut shows the correct application icon that was set in the .desktop file; however, once launched, the application icon does not show on the dock. The default Java icon is shown in place of it.

This is how it looks on Desktop:

On the Desktop

But on Dock it shows Java icon:

On the Dock

I'm also not sure why, the correct application name doesn't appear when I hover over the icon on the dock - it names the java launcher instead.

.desktop:

#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Name=NMRViewJ
Exec="/home/issac/NMRViewJ/NMRViewJ"
Icon=/home/issac/NMRViewJ/.install4j/NMRViewJ.png
StartupWMClass = sun-awt-X11-XFramePeer
Categories=Application;
5

This will be fixed in install4j 8.0 in about 2 weeks (source: I work for the company who develops install4j).

The main problem is that the WMClass property of AWT windows is set to the main class. This means that the main class must be unique for the application, but install4j inserts its own main class which up to 7.0 is always the same. As a workaround, you could change internal state of the AWT toolkit reflectively:

Class<?> toolkitClass = Toolkit.getDefaultToolkit().getClass();

if (toolkitClass.getName().equals("sun.awt.X11.XToolkit")) {
    Field awtAppClassName = toolkitClass.getDeclaredField("awtAppClassName");
    awtAppClassName.setAccessible(true);
    awtAppClassName.set(null, "<my unique application name>");
}

In install4j 8.0, a unique main class will be generated and the generated .desktop file will include a corresponding StartupWMClass entry.

2
  • 2
    We do appreciate the notification, but there is some concern that brevity of answer —even from a product owner— falls short of our requirements for a full answer. Do you have some sort of public bug tracker for this issue that the OP could verify their problem against? – Oli Jun 23 '19 at 9:39
  • Unfortunately, I have no public bug tracker. I'll expand the answer a bit. – Ingo Kegel Jun 23 '19 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.