Packaging and Executing Custom Code

InstallAnywhere 2017

Custom code can extend the functionality of your installer. The following procedure explains how to ensure that your custom code compiles and executes correctly for use with InstallAnywhere.

To create and use custom code in an installer:

1. Add IAClasses.zip to the classpath. The Java compiler needs to reference the classes in this file when compiling the code. IAClasses.zip is located in the root installation directory of InstallAnywhere.
2. Add the action, panel, console, or rule to your project. A good starting point is to use the Java source file templates in the CustomCode/Templates folder, which is available in the InstallAnywhere installation directory.
3. Compile the source files.
4. Decide which additional files and resources your custom code requires. For example, your code may require images, text files, or other resources.
5. Create a Java archive file (.jar) that contains the compiled class files and resource files.

Note • Make sure that the JAR file has full path information in it. (Each file in the archive should be stored with its proper package path.) Without the path information in the JAR file, Java will not be able to properly find the packaged class files.

It is critical that the custom code JAR does not include the classes and resources from IAClasses.zip since this would seriously affect the behavior of the installer and uninstaller.

6. Add to your project an action or rule that you want to execute custom code. To learn more, see the following:
Adding Actions to the Install Sequence
Defining Rules and Rule Expressions that Evaluate Conditions on Target Systems
7. For your action or rule, select the JAR file that contains your custom code, and enter the fully qualified package and class name, such as: com.acme.MyAction.
8. Configure the action’s or rule’s options and add necessary dependencies.

Note • Custom code that uses the InstallShieldUniversalRegistry service needs to add hsqldb.jar as a dependency. Click Add jar or zip, locate hsqldb.jar in <InstallAnywhere>\resource\dbclients, and click Open.

9. Test and debug the action or panel.

Since InstallAnywhere cannot be run from within an integrated development environment, the best ways to debug the custom code are to use the Output Debug Information action or System.out.println(); statements to print debug output to the console during testing.

A frequent source of trouble with custom code is incompatibility between the JDK with which you compile your code and the JVM that you bundle with your installer. Ensure your Java compiler is compatible with your installers’ bundled JVMs.

See Also