Cannot Rerun Java JPAckage Installer If Already Installed, Second Time Just Exits Without Warning

Cannot rerun Java JPackage installer if already installed, second time just exits without warning

No idea if this helps on Mac or Linux but the Windows installer automatically removes older versions of the application when you run it so you just need to set up a scheme which changes the version number on each build to avoid having to ununstall old version each time.

To do this simply you could set the version number as "YY.MM.DDHH" so version number changes each hour and cuts down on uninstalls.

Ant steps:

<tstamp>
<format property="appver" pattern="yy.MM.ddHH" />
</tstamp>

<exec executable="jpackage">
<arg line="--app-version ${appver}"/>
...
</exec>

The CMD version of this:

set appver=%date:~6,2%.%date:~3,2%.%date:~0,2%%time:~0,2%
jpackage --app-version %appver% ...

Jpackage MSI upgrade does not complete if application is open

Alright, I've done some digging and this is related to JavaFX's lifecycle. Simply overriding the Application.stop method is not enough to properly shutdown on these types of close requests.

Two changes to my application fixed the issue:

Register a EventHandler on the primary stage onCloseRequest

Here I initialize my spring application as well as register the event handler to stop the application:

@Override
public void start(Stage stage) {
applicationContext.publishEvent(new StageReadyEvent(stage));
stage.setOnCloseRequest(event -> stop());
}

Ensure you have a call to System.exit in your EventHandler

Platform.exit is not enough to close the application under these circumstances:

@Override
public void stop() {
log.info("Shutting down application...");
applicationContext.close();
Platform.exit();
log.info("Shutdown complete");

// System.exit is required or the app will move to a background process on uninstall/upgrade
// events from Windows MSI installer
System.exit(0);
}

How to set custom installation directory for a java application that is installed by a packaged installer(created with Jpackage)?

Add --win-dir-chooser parameter. Reading the documentation for jpackage or using jpackage --help would get this answer this faster than you can type this question on Stackoverflow!



Related Topics



Leave a reply



Submit