UPDATE: As researched by the original poster, this issue turned out to be a know problem that is not related to Windows Installer. The solution is described here: https://bugs.openjdk.java.net/browse/JDK-8184984 (essentially involving cleanup of some lock files).
Original answer here:
Before trying anything else, please try this option and let us know if it solved the problem (I haven't had any concrete problems to test it with for a while - these tools tend to get deprecated):
Several such cleanup tools have come and gone - all deprecated and unsupported as of now (MsiZap.exe for example).
I am not sure if your installer is Windows Installer based - since you have added that tag to your question I just assume so.
Please don't ever listen to advice telling you to disable the Windows Installer service. Those "hacks" can wreck your system. In fact if you have done any changes and the service won't start and you are unable to change things back, then your best options might be the "Last Known Good Configuration" feature (activated by pressing F8 during system boot on Windows systems before Windows 10), or "System Restore" (the latter may also fix your stuck Java package, but I don't like this feature - I have seen other, unrecoverable installation / uninstallation problems occur when it is used - try as a last resort - maybe if the above tool doesn't help).
Some links - just for reference and easy retrieval: