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:
[Desktop Entry] Type=Application Name=Java Application Launcher Icon=java Exec=/usr/bin/java -jar %U Categories=Application;Java Terminal=False
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