Thursday, December 20, 2007

Creating and running Custom code for installation

InstallAnywhere provides support to run Custom Java code during installation of product. Although IA has added many custom features which saves lot of your development time but some times it becomes a necessity to write a custom code.
 
The Java code can be written in any development environment, the class has to extend from CustomCodeAction of InstallAnywhere. The use then has to override the install and un-install methods of the base class. Please find the snippet of the sample code below.
 
public class code extends CustomCodeAction
{
 public void install(InstallerProxy proxy) throws InstallException
 {
 }
 public void uninstall(UninstallerProxy Uproxy) throws InstallException
 {
 }
}
 
Its very simple to write custom for IA.
 
Once the Java file is compiled using the IAClasses.zip in the class path, create a .jar or .zip file for the class file.
 
Now go to the advance designer right click on Run Custom Code in the Install section. This will allow you to add a custom action to you installation project. In the properties of the run custom code action browse the .zip file and for the class name provide the fully qualified class file name like com.company.product.ClassFileName
 
Make sure that you are bundling the same VM pack with the installer that you have used to compile your Java code, other wise you might get errors during installation like could not find class com.company.product.ClassFileName
 
Happy developing your custom actions, if you have any questions on custom code feel free to put comments on the post or write to mailto:jha.yogi@gmail.com
 

No comments: