Reputation: 13210
Previously I used Izpack to install my Java application, and when users want to install a new version they just reinstalled into the same location (C"/Program Files/Jthink/Jaikoz"), this would replace older files with newer files, and there was no need for user to uninstall old version first.
I have now built a installer using JPackage (now part of Java, JDK 14) for the latest version of the application, this continues to install to same location. The trouble is because JPackage enforces a new file structure (app and runtime subdirs) my files are no longer overwriting my existing files, so now I have the two installations all muddled up.
So I added some code in the latest version to delete the old no longer needed files when I started my application. But the trouble is this fails because I do not have permission to delete these files, I think this is because they were installed by installer (I am not sure)
e.g here we show groups of old files, only System and Administrators have permissions to modify/delete the files.
If I Run as Administrator then the code deletes the files without problem, but it is not usual for customer to run as administrator so this is no great help.
What are my options ?
Upvotes: 3
Views: 1180
Reputation: 444
If you pass the argument "--win-per-user-install" to your jpackage command the msi will install the application under "C:/User/x/AppData/Local" and will have permission to write inside its own folder.
That only helps to cleanup files in the future, but old ones under C:/Programme I'm afraid I also don't know. If you can read the folder with your application. You certainly can give instructions from your application how users can cleanup old stuff themselves if you detect old files.
Upvotes: 0
Reputation: 1384
It seems that you have to pass the following argument to jpackage to identify installers for the same application: --win-upgrade-uuid "your_uuid_string". As ever with Java/Oracle documentation, they could not have been more mysterious about this if they tried.
I've also found that I have to increment the version number, too, or else the installer will flash quickly and just hang in the background and do nothing (until you reboot or end the task): --app-version 1.0.1
You can generate a UUID here: https://www.uuidgenerator.net/
Upvotes: 4