Response Files


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 installer variables. All screens and form components provided by install4j ensure that user input is bound to appropriate installer variables that are registered for being written to the response file.

Installer variable values are of the general type java.lang.Object. In a response file, only variables with values of certain types can be represented: In addition to the default type java.lang.String, 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

String variableName = ...;
context.registerResponseFileVariable(variableName);

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. 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 command line 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 are realized as installer variables as soon as the response file is loaded. 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 checkbox 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)