I just started using jpackage and it is a really great tool. One single step takes a lot of work off my shoulders. The more surprised I am about something that looks hardcoded and cannot be customized?
JPackage automatically generates the launcher (lib/<application>.desktop
file), and the deb package automatically installs it such that all users can launch the application. But as soon as it is launched, another icon pops up in unity. I expected that the existing icon is marked as running.
According to Ubuntu DEB installer makes all Java applications have the same icon we just need to ensure the .desktop file contains the correct StartupWMClass
. Using xprop I found out this value is based on the fully qualified class name responsible for the window - which makes absolute sense.
So how can I tell jpackage which StartupWMClass to set in the generated .desktop file?
Edit: To complement Bodo's comment I will show how I call jpackage. In fact I am not running a command line myself - instead I am using the maven plugin configured as:
<plugin>
<groupId>com.github.akman</groupId>
<artifactId>jpackage-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jpackage</goal>
</goals>
<configuration>
<dest>target</dest>
<name>OoliteCommunicator</name>
<type>PLATFORM</type>
<appversion>${project.version}</appversion>
<description>Oolite Communicator is an add-on for Oolite to allow multiplayer interaction. (check http://oolite.org)</description>
<vendor>Hiran</vendor>
<icon>target/classes/com/mycompany/oolitecommunicator/ui/Communicator_Logo_Icon.png</icon>
<input>target/dist</input>
<mainjar>OoliteCommunicator-${project.version}.jar</mainjar>
<mainclass>com.mycompany.oolitecommunicator.Main</mainclass>
</configuration>
</execution>
</executions>
</plugin>
What I can see during the maven build is this output, which I believe to be the command line generated internally when the plugin invokes jpackage. The last line may be the invocation already, and whenever I check after the build there is no file /home/hiran/NetBeansProjects/OoliteCommunicator/target/jpackage.opts. I can only assume it's content was logged just before.
# jpackage
--dest /home/hiran/NetBeansProjects/OoliteCommunicator/target
--app-version '1.0-20211220-090022'
--description 'Oolite Communicator is an add-on for Oolite to allow multiplayer interaction. (check http://oolite.org)'
--name 'OoliteCommunicator'
--vendor 'Hiran'
--icon /home/hiran/NetBeansProjects/OoliteCommunicator/target/classes/com/mycompany/oolitecommunicator/ui/Communicator_Logo_Icon.png
--input /home/hiran/NetBeansProjects/OoliteCommunicator/target/dist
--main-jar 'OoliteCommunicator-1.0-20211220-090022.jar'
--main-class com.mycompany.oolitecommunicator.Main
/usr/lib/jvm/java-16-openjdk-amd64/bin/jpackage @/home/hiran/NetBeansProjects/OoliteCommunicator/target/jpackage.opts
Finaly I get a deb package with this desktop file:
[Desktop Entry]
Name=OoliteCommunicator
Comment=Oolite Communicator is an add-on for Oolite to allow multiplayer interaction. (check http://oolite.org)
Exec=/opt/oolitecommunicator/bin/OoliteCommunicator
Icon=/opt/oolitecommunicator/lib/OoliteCommunicator.png
Terminal=false
Type=Application
Categories=Unknown
MimeType=
and I fixed the bhaviour by manually adding the line
StartupWMClass=com-mycompany-oolitecommunicator-Main
So my workaround is to add this line to both
- /opt/oolitecommunicator/lib/oolitecommunicator-OoliteCommunicator.desktop
- /usr/share/applications/oolitecommunicator-OoliteCommunicator.desktop
after the deb has been installed. Not that easy as jpackage was intended for I guess...
jpackage
command you are using, and if you use@filename
, the contents of the file. – Rockling/home/hiran/NetBeansProjects/OoliteCommunicator/target/jpackage.opts
may also be important. I suggest to try--main-class class name
, see docs.oracle.com/en/java/javase/14/docs/specs/man/… – RocklingStartupWMClass
line in the launcher file. If you don't see a file/home/hiran/NetBeansProjects/OoliteCommunicator/target/jpackage.opts
then this file probably gets generated automatically before running the command and deleted afterwards. Sorry, my suggestion was based on the documentation only. I can only suggest to runjpackage
manually and experiment with the options to find out if you can somehow get it to create the .desktop file as required. Then proceed to themaven
integration. – Rockling