install4j application name in Gnome 3

别说谁变了你拦得住时间么 提交于 2019-12-11 02:42:15

问题


When our application is installed by install4j on a Gnome 3 desktop in Linux, and the application runs: the Application menu, located beside the Activities button which shows the name of the active application is showing "com-install4j-runtime-launcher-UnixLauncher".

Is there a setting in install4j so that our application name shows up properly instead?


回答1:


As of install4j 7, there is only a hack to achieve this:

Define the compiler variable

sys.ext.windowClass.<nn>=MyAppName

where <nn> is the ID of the launcher and MyAppName must not contain spaces.

This will add a "StartupWMClass" entry to the .desktop file.

For the AWT, the actual window class has to be set to the same value programmatically. This is not possible with an API, but just by using reflection:

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

if (Objects.equals("sun.awt.X11.XToolkit", toolkitClass.getName())) {
    //noinspection JavaReflectionMemberAccess
    Field awtAppClassName = toolkitClass.getDeclaredField("awtAppClassName");
    awtAppClassName.setAccessible(true);
    awtAppClassName.set(null, wmClass);
}


来源:https://stackoverflow.com/questions/50117380/install4j-application-name-in-gnome-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!