Response Files


Introduction

With a response file you can change the default user selection in all screens. A response file is a text file with name value pairs that represent certain installer variables. All screens provided by install4j ensure that they write all user selections to appropriate installer variables and bind their user interface components to these variables. This includes form screens.

Installer variable values are of the general type java.lang.Object. In a response file, only variables with values of certain types are included: The default type is java.lang.String. In addition the types java.lang.Boolean, java.lang.Integer, java.util.Date, java.lang.String[] and int[] are supported. In order to let the installer runtime know about these non-default types, the variable name in the response file is followed by a '$' sign and an encoding specifier like 'Integer' or 'Boolean'.

Response file variables are variables that have been registered with context.registerResponseFileVariable(...) in the installer. All variables that are bound to form components are automatically registered as response file variables. Also, system screens register response file variables as needed to capture user input.

All installer variables live in the same name space. If you use an installer variable more than once for different user inputs, the response file only captures the last user input and may lead to erroneous behavior when the installer is run with a response file. If you would like to optimize your installers for use with a response file, you have to make sure that the relevant variable names are unique within your installer.

A response file can be used to

When applying a response file to an installer, all variable definitions are translated into installer variables. The response file shares the same mechanism with the variable file offered by the -varfile installer option. You can add the contents of a response file to a variable file and vice versa.

Generating response files

There are two ways to generate a response file:

Applying response files

When an installer is executed, it checks whether a file with the same name and the extension .varfile can be found in the same directory and loads that file as the response file. For example, if an installer is called hello_setup.exe on Windows, the response file next to it has to be named hello_setup.varfile.

You can also specify a response file explicitly with the -varfile installer option.

Response files work with all three installer modes, GUI, console and unattended.

Response file variables

The variables that you see in the response file exist at runtime independently of the response file. You can use these installer variables to access or change user selections on system screens. For example, the "Create program group" screen on Windows binds the user selection for the check box that asks the user whether to create the program group for all users to the variable sys.programGroup.allUsers. To access the current user selection from somewhere else, you can use the expression

context.getBooleanVariable("sys.programGroup.allUsers")

To change that selection, you can invoke

context.setVariable("sys.programGroup.allUsers", Boolean.FALSE)