问题
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