After a jpackage application has been installed, how can I allow my users to upgrade the application without requiring them to run the installer all over again? What options do I have to allow users to upgrade?
An ideal scenario is that the underlying jars would be swapped out at runtime, and the application would be restarted in the same process. I imagine this probably isn't possible though?
See jpackage Options. The jpackage tool will take as input a Java application and a Java run-time image, and produce a Java application image that includes all the necessary dependencies. It will be able to produce a native package in a platform-specific format, such as an exe on Windows or a dmg on macOS.
Though jpackage only supports JDK11+, you can still build traditional non-modular apps. This is the simplest example to demonstrate how jpackage works. You take an executable jar file, in this case myapp.jar, and specify the class inside that you want to execute.
The dependencies (i.e., the other packages that a package needs to install or work) themselves may have dependencies that you don't already have installed. Once you know what packages you need, you can download them. I suggest using Launchpad for this, because the downloads are SSL-encrypted, which helps prevent file corruption.
If you already have a runtime image with the modules in it, you can simply tell jpackage to use the runtime image you want with the --runtime-image option. Specify the main class with the --module option. To learn how to create a custom runtime, check out my tutorial How to Create Java Runtime Images with jlink.
jpackage doesn't currently support auto update although they are planning to support it in future I think.
Until then, you can use this java library:
https://github.com/threerings/getdown
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With