## Updates |

### 1. Introduction

installers generated by install4j actively handle updates. On the Update Options tab in the installer section, you can configure how an installer should behave in the event of an update. An update occurs when the user installs an application into a directory where an installation with the same application id already exists.

Typically, minor upgrades of an application should be installed into the same directory as earlier installations. The default behavior of install4j is to suggest the previous installation directory and program group, so that the user is guided into installing the application into the same directory. If this behavior is not desired, you can switch off these suggestions or change the application id.

### 2. Updates into the same installation directory

The following points are of interest with respect to updates into the same installation directory:

- Generated installers will refuse to install on top of installations with a different application ID by default. You can change this behavior on the "Installation location" screen.

  Note: installers generated with install4j <= 3.0.x do no have an application ID, it is always possible to install on top of such an installation.

- Generated installers will detect if any of the previously installed launchers are still running and will ask the user to shutdown these applications. This happens when the "Install files" action is executed.
- Deployed services will be stopped and uninstalled before the installation. This happens when the "Install files" action is executed. You can optionally stop your services earlier with the "Stop a service" action if your update process requires it.
- During an update, the installation databases will be merged, so that files, menu entries, file associations, etc. of old installations can still be uninstalled when the uninstaller is executed.
- After an update, only the (optional) uninstall actions of the newer installation will be executed when the uninstaller is executed. However, the auto-uninstall actions from previous installations will be executed, too (for example the uninstallation of a service that is automatically registered by an "Install service" action during installation).

If you would like to uninstall the previous installation before installing any new files, you can add the "Uninstall previous installation" action before the "Install files" action. In this context, the uninstallation policies that exclude updates are of interest. With these uninstallation policies you can preserve certain files for updates, but uninstall them when the user manually invokes the uninstaller. The uninstaller invoked by the "Uninstall previous installation" action is running in unattended mode. You can use `context.isUninstallForUpgrade()` to exclude certain actions for an update uninstaller.

### 3. Add-on installers

For distributing enhancements and patches, install4j offers the add-on installer type that can be configured on the Update Options tab in the installer section.

An add-on installer will only install on top of an installation of a specified application id. It does not have a separate uninstaller.