Using variables in install4j projects

  
 previous up next 


  Most text fields in install4j have a   variable selector next to them. In these text fields you can use variables. Variables are always written in the form %VARIABLE%, i.e. surrounded by percent signs. To use a percent sign in text fields that support variables, just double the percent sign. Variables are either
  • system variables
    System variables are variables that are defined by install4j. Some system variables only make sense in the media file wizard. System variables include:
    • VERSION
      The application version as entered on the application info tab. Dots ('.') will be converted to underscores ('_') for this variable.
    • SHORT_NAME
      The short name of the application as entered on the application info tab. If the default name of the media set is not suitable, you can rename the media set.
    • SETNAME
      The name of the media file definition. Can only be used in the media file wizard and the media file name template.
    • PLATFORM
      A short identifier for the platform (windows, linux, unix, mac). This variable depends on your choice in the first step of any of the media set wizards. Can only be used in the media file wizard and the media file name template.
    • LANGUAGE_ID
      The 2-letter ISO 639 code (see http://www.w3.org/WAI/ER/IG/ert/iso639.htm) for the language of the installer. Can only be used in the media file wizard and the media file name template. This variable can also be defined on the command line or the ant task.
    • WITH_JRE
      A variable that contains "_with_jre" if a JRE is statically bundled with a media file and the empty string if not. This is useful if media files with and without JRE are built. Can only be used in the media file wizard and the media file name template.
    • DATE
      The current date in the format YYYYMMDD (e.g. "20040910")

    In the VM parameters text field for the launcher definition, you can also use the variable INSTALL4J_EXEDIR which is evaluated at runtime and contains the directory of the executable, as well as the variable INSTALL4J_PATHLIST_SEPARATOR which contains the path separator for the target platform. INSTALL4J_JVM_HOME contains the directory of the JRE that your executable is running with.

  • user variables
    User variables are variables that you define on the user variables tab of the general settings step. User variables can be overridden

    User variables are useful to internationalize certain text field values such as the product name or the names of installation components or to customize certain aspects of launchers and installers on a per-media file basis.

  When you use a variable name in your project that is not a system variable, it must be defined in on the user variables tab of the general settings step. If an unknown variable is encountered, the build will fail. You can use other variables in the value of variables. Recursive definitions are detected and lead to a failure of the build. It is not possible to define user variables with the name of a system variable.

To see all variable replacements, switch on extra verbose output in the build step.

  User variables definitions are also available at runtime in your custom actions and custom screens. The getUserVariableValue() method of the context object gives access to all variable values.