问题
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 !
回答1:
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% ...
回答2:
This may fix the reinstall.
In my case, I create the jpackage installer, install it, creates a new installer (based on Inno Setup) and uninstall the jpackage automatically.
I think what may work in your case is to uninstall the first installation as the installer may detect that it's already installed with the same version.
In my case I do the uninstall automatically with an Ant task
<target name="uninstall" depends="init">
<exec executable="wmic.exe">
<arg value="product" />
<arg value="where" />
<arg value="description='${full.name}'" />
<arg value="uninstall" />
</exec>
</target>
来源:https://stackoverflow.com/questions/62675323/cannot-rerun-java-jpackage-installer-if-already-installed-second-time-just-exit