Monday, June 29, 2009

Adding external jar to your CustomCodeAction

[Question]

In GUI mode, the installer launches and installs, and after the installation executes a PostInstall Action which runs a Script/Batch file. In this Script file we call another Java class which is interactive. (means it gets input and outputs messages on the same window or a separate window). The dependencies are added in the batch/script file using export Library Path

Now I want to emulate this in Console Mode. I want to call this class from Console Mode Custom Code execution action so that the input and output are done on the Console mode Installer. The class which is called in turn depends on a lot of 3rd party jars. As soon as I add dependencies for the 3rd party signed jars it always gives exception "no manifest section for signature file entry" .
Since the jars are 3rd party, I can't go back and modify the jar contents. Is there anyway to overcome this problem ?

[ANSWER]

If you are calling your java class from a script/batch file add the dependency of your 3rd party jar files in the script itself instead of adding dependency in the IA project. Since the java class file is called from a script which spawns a different process and into a new shell the dependencies added to the main project does not get resolved while loading the class file into the JRE when spawned through script/batch.
InstallAnywhere's feature of adding files into class path or adding dependencies only works correctly in case of custom code action.

To load the 3rd party jars when using with shell use the following java arguments in the shell script to execute it.

java -cp abc.jar;xerces.jar;ant.jar com.yourcompany.packagename.ClassName

Here -cp added to the Java command tells the JRE to load abc.jar, xerces.jar and ant.jar to be added in the class path for executing the com.yourcompany.packagename.ClassName class file.

1 comment:

Amit said...

DYNAMIC INSTALLER(BUILD.PROPERTIES)
Hi All,
As we are creating a dynamic installer(installanywhere 2008)
through "build.properties" using Properties file reader plugin.By using "build.properties" we can change another product installer by giving diffrent ProductName,shortcutName,Diffrent registry entry etc..

But we are unable to provide diffrent PRODUCT VERSION, PRODUCT ID,SPLASH SCREEN,DLL HANDLING THROUGH INSTALLER.

does any work in .properties file or if there is any work arround to get "PRODUCT VERSION", "PRODUCT ID","SPLASH SCREEN","DLL HANDLING" dynamically as our requirement is not to create installer again and again for future product of the same type but diffrent version.