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 ?