How Installers Find a JRE

## How Installers Find a JRE |

Installers generated by install4j are native and can start running without a JRE. However, the installer itself requires a JRE in order to perform its work and so the first action of the installer is to locate a JRE that is suitable for both the installer and your application. In this process it performs the following steps:

- Look for a statically bundled JRE. If a statically bundled JRE is included with the installer, it will unpack it and use it. First, this JRE is unpacked to a temporary directory, later it is copied to a location that depends on whether the bundled JRE is configured as shared or not.
  - Not shared
    It is copied to the `jre` directory in the installation directory of your application. No other installer generated by install4j will find this JRE. It will not be made publically available (e.g. in the Windows registry).
  - Shared

    It is copied to the `i4j_jres` directory in a common folder which depends on the operating system:

    - `C:\Program Files\Common Files` on Microsoft Windows with an English locale.
    - `/opt` if it exists, otherwise `/usr/local` on Unix.

    If the above folder is not writable, the `i4j_jres` directory will be created in the use home directory and the shared JRE will only be shared for the current user.

    Other installers generated by install4j will find this JRE. It will not be made publically available (e.g. in the Windows registry). For each Java version, only one such JRE can be installed. Shared JREs are never uninstalled.

  Your application will also use the JRE selected by the installer.

- Look for a suitable JRE in the configured search sequence. The installer uses the same search sequence and Java version contraints as your launchers which are configured for the entire project. The most important search sequence element in this respect is the "Search Windows registry and standard locations" entry. On Microsoft Windows the registry contains information on installed JREs, on Unix platforms there is a number of standard locations which are checked, on Mac OS X the location of installed JREs is always the same.
- If no JRE has been found, the installer notifies the user

  and offers the following options:

  - Download a dynamically bundled JRE

    as configured in the Bundled JRE step of the media wizard.

  - Manually locate a JRE
  - Cancel the installation

  You can force the installer to skip the first two steps and show this dialog immediately with the `-manual` command line parameter.