InstallerSessionBuilder (install4j API)
Description: declaration: package: com.install4j.api.test.session, class: InstallerSessionBuilder

# Class InstallerSessionBuilder

java.lang.Object
com.install4j.api.test.session.AbstractSessionBuilder
com.install4j.api.test.session.InstallerSessionBuilder

public final class InstallerSessionBuilder extends AbstractSessionBuilder
Builds and starts an `InstallerSession` for the install4j installer.

    try (InstallerSession session = InstallerSessionBuilder
            .forMediaFile(new File("build/media/myapp-linux-x64.sh"))
            .installationDirectory(new File(tempDir, "install"))
            .start()) {
        session.currentScreen().clickNext();
        ...
    }

## Kotlin extensions

`SessionExtensions.kt` in this package adds `useSession { ... }` as a Kotlin inline extension: it calls `start()`, runs the trailing lambda on the resulting `InstallerSession` as `this`, and closes the session afterwards.

    InstallerSessionBuilder.forMediaFile(media).useSession {
        onScreen("welcome") { clickNext() }
        // ...
    }

- ## Method Summary

  Modifier and Type
  Method
  Description
  `InstallerSessionBuilder`
  `arg(String... args)`
  Additional command-line arguments passed to the installer application.
  `InstallerSessionBuilder`
  `debug(boolean debug)`
  Switch the session to in-process debug mode.
  `static InstallerSessionBuilder`
  `forMediaFile(File mediaFile)`
  Create a builder for the given installer media file with extension `.exe`, `.sh` or `.dmg`.
  `InstallerSessionBuilder`
  `installationDirectory(File target)`
  Target directory where the installer should install files.
  `InstallerSessionBuilder`
  `logFile(File logFile)`
  Redirect install4j's runtime logger output to the given file.
  `InstallerSession`
  `start()`
  Start the installer application and return the typed session handle.
  `InstallerSessionBuilder`
  `systemProperty(String key, String value)`
  Set a system property on the test JVM before the installer starts.
  `InstallerSessionBuilder`
  `timeout(Duration d)`
  Default timeout applied to every wait operation.
  `InstallerSessionBuilder`
  `workingDirectory(File dir)`
  Working directory for the running installer application.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### forMediaFile

    @NotNull public static InstallerSessionBuilder forMediaFile(@NotNull File mediaFile)
    Create a builder for the given installer media file with extension `.exe`, `.sh` or `.dmg`. The file is extracted on first use and cached on disk for subsequent runs.

  - ### installationDirectory

    @NotNull public InstallerSessionBuilder installationDirectory(@NotNull File target)
    Target directory where the installer should install files. If not set, the session creates a temporary directory and deletes it on `Session.close()`. User-provided directories are never deleted.

  - ### timeout

    @NotNull public InstallerSessionBuilder timeout(@NotNull Duration d)
    Description copied from class: `AbstractSessionBuilder`
    Default timeout applied to every wait operation. The default is 3 minutes. Override per session for longer installations.
    Overrides:
      `timeout` in class `AbstractSessionBuilder`

  - ### arg

    @NotNull public InstallerSessionBuilder arg(@NotNull String... args)
    Description copied from class: `AbstractSessionBuilder`
    Additional command-line arguments passed to the installer application.
    Overrides:
      `arg` in class `AbstractSessionBuilder`

  - ### systemProperty

    @NotNull public InstallerSessionBuilder systemProperty(@NotNull String key, @NotNull String value)
    Description copied from class: `AbstractSessionBuilder`
    Set a system property on the test JVM before the installer starts.
    Overrides:
      `systemProperty` in class `AbstractSessionBuilder`

  - ### workingDirectory

    @NotNull public InstallerSessionBuilder workingDirectory(@NotNull File dir)
    Description copied from class: `AbstractSessionBuilder`
    Working directory for the running installer application.
    Overrides:
      `workingDirectory` in class `AbstractSessionBuilder`

  - ### logFile

    @NotNull public InstallerSessionBuilder logFile(@NotNull File logFile)
    Description copied from class: `AbstractSessionBuilder`
    Redirect install4j's runtime logger output to the given file.
    Overrides:
      `logFile` in class `AbstractSessionBuilder`

  - ### debug

    @NotNull public InstallerSessionBuilder debug(boolean debug)
    Description copied from class: `AbstractSessionBuilder`
    Switch the session to in-process debug mode. By default the test API spawns the produced installer media as a real subprocess (with its bundled JRE, native launcher, and the full extraction code path) and drives it over IPC. In debug mode it runs the installer in the test JVM directly, which is faster but requires an `install4jc -g` debug build to exist alongside the media file. Use debug mode locally during development; leave it off for CI runs that should exercise the real installer.
    Overrides:
      `debug` in class `AbstractSessionBuilder`

  - ### start

    @NotNull public InstallerSession start()
    Description copied from class: `AbstractSessionBuilder`
    Start the installer application and return the typed session handle.
    Specified by:
      `start` in class `AbstractSessionBuilder`