Installer - Custom Code & Resources


  Custom code is used for
  • specifying additional libraries that can be used in scripts and expressions of screens, actions and form components.
  • developing new types of actions, screens or form components with the install4j API. Please see the help topic on using the API for more information.

    Before you start to develop a new action, please have a look at the available actions and screens. If it's just a few lines of code, you can use the "Run script" action to enter them directly into install4j. If you would like to collect user input, most use cases can be solved with a "Configurable form" screen.

    An alternative way of adding your beans to the install4j is packaging them as an extension. In that case, you can select them directly from the standard registry dialogs instead of having to go through the "Search in custom code" menu entries when adding beans to the installer.

  • including resource files into the installer. Resource files are arbitrary files like DLLs, external executables or text files that have to be available before the "Install files" action has run. While all class files are packed into a single user.jar file, archives and resource file are extracted to the user subdirectory in the working directory of the installer. You can access a resource file with the following expression:
    new File("user", "[file name]")
    For example, if you have added a native library jni.dll to your custom code, you can load it in a "Run script" action by calling
    System.load(new File("user", "jni.dll").getPath());
  In the Custom code section you can specify the location of your custom code. The following custom code location types are available:
  •  Class or resource files
  •  Directories
  •  Archives
All classes used by your custom code have to be included in these locations (except for Java runtime classes and install4j framework classes). The control buttons allow you to modify the contents of the list of custom code locations, the  Add button displays the custom code entry dialog.

After you have chosen your custom code locations, you will be able to select your own screens, actions and form components.

  Files that are present in both the custom code as well as the distribution tree will not be packaged twice. You can add files that are also in the distribution tree freely to your custom code, they will not increase the size of your installer. The compiler checks the source path of included files to determine if they are already present in the installer.