Search code examples
javainstallationjava-14jpackage

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


Cannot rerun JPackage installer if already installed, second time just seems to exit without warning, is this correct behaviour on Windows ?

You may ask why I want to do this anyway?

Well in my case I am trying to build a JPackage installer for my Java application, so I am building it installing it, then tweaking the settings, rebuilding it and try to reinstall. It took me some time to work out that I couldn't not reinstall it unless i uninstall the first installation (using Control Panel, Program and Features)

My case may not be the usual usecase, but it doesn't feel correct that it just exits without giving any reason.

It also means that if I deploy a new version to customers, and I later need to amend the installer than I would have to modify the version number to let the user reinstall, this may generally be best practise but is something I would not particulary want to do if the application itself had not changed.

Update:Since found out by looking at TaskManager it is still running but doesnt seem to be doing anything and gives no indication to user !


Solution

  • 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% ...
    

    Linux:

    appver=$(date +%y.%m.%d%H)
    jpackage --app-version $appver