1

In my environment we have a lot of executable capsule jars which - depending on the environment they connect to - set a custom icon and name programmatically. This is done by calling javax.swing.JFrame.setIconImage and setTitle on startup. We have a centralized dashboard where we can download the executable jars (several 100 different ones), so obviously, I want to be able to download one and run it directly. For this, there are guides all over the internet, and I came up with the normal solution:

.local/share/applications/java-jar-launcher.desktop:

[Desktop Entry]
Type=Application
Name=Java Application Launcher
Icon=java
Exec=/usr/bin/java -jar %U
Categories=Application;Java
Terminal=False

.local/share/applications/mimeapps.list contains:

application/x-java-archive=java-jar-launcher.desktop

However, this does not respect the icon as set by the application, there is only the grey questionmark. Even more frustrating, all applications and all opened windows end up in the same spot in the dock, indistinguishable from each other, all named Java Application Launcher.

If I start a downloaded jar from a terminal through java -jar, both the icon as well as it's programmatically set name are visible in the dock, separating different applications from each other.

How can I get the jars to be launchable automatically and also preserve the icon and the name? I cannot create 100s of desktop files as this is not a fixed set of applications.

Running Ubuntu 15.10 / Java 1.8.0_66

0

To get rid of the gray question mark, you add this line of code:

stage.getIcons().add(new Image(getClass().getResourceAsStream("/Images/orca.png")));

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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