How to execute a custom java code during pre installation and pre uninstallation.


1 comment

  • Avatar

    Running Java applications after installation - such as during Post Installation or Pre Uninstallation should work normally. You can simply use runProgram, such as:

      <programArguments>-jar "path/to/app.jar"</programArguments>

    The above will work if the installer deploys Java runtime into ${installdir}/jre.

    However, running Java in Pre Installation is a bit more difficult - since it will require unpacking entire JRE to a temporary directory.

    Assuming you bundle your Java as "jre-${platform_name}" (i.e. jre-linux, jre-windows, jre-linux-x64) folder in "jre" component, it would require the following actions:

    <!-- delete directory if it existed -->
    <!-- unpack JRE -->
    <!-- unpack JAR that is needed -->
    <!-- run the application -->
       <programArguments>-jar test.jar</programArguments>
    <!-- clean up -->

    The jars are assumed to be a test.jar file in "jars" component, "jars" folder.

    The names of components and folders are the short names (<name> tag) for components and folders that contain JRE and JAR files respectively.

    You can find more information on unpacking files before installation here

Please sign in to leave a comment.