I'm trying to create an AppImage using JPackage (On a Ubuntu 18.04 System using OpenJDK 14)
All the examples I find are of the form
jpackage --type app-image --name myappimage --input target --main-jar myuberjar.jar --main-class myapplication.core --verbose
When I run this I get a directory ./myappimage/
and in ./myappimage/bin/
there is an executable that I can launch to run the application. But the whole thing isn't bundled into one AppImage file as I'd like.
What am I missing here?
While AppImage is a desireable format it is not (yet) supported by JPackage. Although the JPackage Documentation mentions a command line option app-image, it's meaning is different:
--app-image file path Location of the predefined application image that is used to build an installable package (absolute path or relative to the current directory). See create-app-image mode options to create the application image.
So the app-image folder is just the folder where JPackage collects all the bits and pieces for an application before converting that into a native package like deb/msi/dmg. As a result, just do not get confused by the two different yet similarly named concepts.
Your best approach is to use JPackage to assemble everything required (as it is the case for app-image), then take it from there with the tools provided by AppImage.org. Getting more concise:
Tell JPackage to exit after having created the app-image like so:
jpackage --type app-image --dest app-image ...
This will leave you will all files you need collected in the app-image directory. No, not all of them. For my OpenJDK (build 16.0.1+9-Ubuntu-120.04) the JPackage command forgets to create the launcher (*.desktop file), and when finishing the build to a debian package it forgets to install that file. See how I got around that.
From here you need to follow the AppImage packaging guide to create an AppDir directory structure before ultimately calling the packager. I copied the app-image directory into AppDir/usr and created a few symlinks in AppDir. Also needed to create the .desktop file. Most important is a symlink AppDir/AppRun
pointing to the executable in AppDir/usr/bin/... The name of the symlink has to be AppRun.
Finally follow Manual packaging and run the appimagetool. Information how to run it seems only on the README.md. I ended up with an executable with file extension .appimage.
Set executable permissions on that file and run it.