Deploy Netbeans Platform based Application using IzPack Installer
January 2nd, 2008 | by Tonny Kohar |So, you just finished creating Netbeans Platform based Application and ready to deploy it to the users. You might be interested to check IzPack Installer.
IzPack is an installers generator for the Java platform. It produces lightweight installers that can be run on any operating system where a Java virtual machine is available. Depending on the operating system, it can be launched by a double-click or a simple java -jar installer.jar from a shell. The most common use is to distribute applications for the Java platform, but you can also use it for other kinds of projects.
This is what we used in Sketsa SVG Editor and Citra FX Photo Effects. Just change the values in the example below to fit your needs.
Note: this is tested on Netbeans 6 and 5.5
Update: this is based on the following folder/file structure
[your-suite-project-folder]
- [branding]
- [installer]
- [icons]
- [izpack]
- izpack-install-script.xml
- Win-shortcutSpec.xml
- etc (other required izpack resources
eg: image, executable file, etc)
- readme.html
- [legal]
- [nbproject]
Create IzPack Install script
First, you need to create IzPack install script and named it izpack-install-script.xml, similar like below:
<installation version="1.0"> <!-- The info section. The meaning of the tags should be natural ... --> <info> <appname>$APP-NAME</appname> <appversion>$APP-VERSION</appversion> <appsubpath>$APP-PATH</appsubpath> <url>http://www.kiyut.com</url> <authors> <author email="support@kiyut.com" name="Kiyut Software"/> </authors> <uninstaller>yes</uninstaller> <javaversion>1.5</javaversion> </info> <variables> <variable name="JVM_REQ" value="Java VM (JRE) 1.5 or higher"/> <variable name="DesktopShortcutCheckboxEnabled" value="true"/> </variables> <!-- The gui preferences indication. Sets the installer window to 640x480. It will not be able to change the size. --> <guiprefs width="640" height="480" resizable="no"> <modifier key="useButtonIcons" value="no"/> <modifier key="useLabelIcons" value="no"/> <modifier key="allYGap" value="3"/> <modifier key="layoutAnchor" value="NORTHWEST"/> <modifier key="useHeadingPanel" value="yes"/> <modifier key="headingLineCount" value="1"/> <modifier key="headingFontSize" value="1.5"/> <modifier key="headingBackgroundColor" value="0x00ffffff"/> <modifier key="headingPanelCounter" value="text"/> <modifier key="headingPanelCounterPos" value="inHeading"/> </guiprefs> <!-- The locale section. Asks here to include the English and French langpacks. --> <locale> <langpack iso3="eng"/> </locale> <!-- The resources section. The ids must be these ones if you want to use the LicencePanel and/or the InfoPanel. --> <resources> <res id="LicencePanel.licence" src="legal/LICENSE-sketsa.txt"/> <res id="shortcutSpec.xml" src="Win-shortcutSpec.xml"/> <res id="Unix_shortcutSpec.xml" src="Unix-shortcutSpec.xml"/> <res id="Installer.image" src="installer-image.png"/> <res id="XInfoPanel.info" src="XInfoPanel.txt"/> <res id="Heading.image" src="heading-image.png"/> </resources> <!-- The native libraries to add --> <native type="izpack" name="ShellLink.dll"/> <!-- The panels section. We indicate here which panels we want to use. The order will be respected. --> <panels> <panel classname="HelloPanel"/> <panel classname="LicencePanel"/> <panel classname="PacksPanel"/> <panel classname="TargetPanel"/> <panel classname="InstallPanel"/> <panel classname="ShortcutPanel"/> <panel classname="XInfoPanel"/> <!-- <panel classname="FinishPanel"/> --> <panel classname="SimpleFinishPanel"/> </panels> <!-- The packs section. We specify here our packs. --> <packs> <pack name="$APP-NAME" required="yes"> <description>Core Files</description> <file targetdir="$INSTALL_PATH" src="bin" override="true" /> <file targetdir="$INSTALL_PATH" src="etc" override="true" /> <file targetdir="$INSTALL_PATH" src="harness" override="true" /> <file targetdir="$INSTALL_PATH" src="ide8" override="true" /> <file targetdir="$INSTALL_PATH" src="legal" override="true" /> <file targetdir="$INSTALL_PATH" src="platform7" override="true" /> <file targetdir="$INSTALL_PATH" src="sketsa" override="true" /> <file targetdir="$INSTALL_PATH" src="readme.html" override="true" /> <file targetdir="$INSTALL_PATH/Uninstaller" src="uninstaller.exe" override="true" /> <file targetdir="$INSTALL_PATH/Uninstaller" src="uninstaller" override="true" /> <executable targetfile="$INSTALL_PATH/bin/sketsa" stage="never"/> <executable targetfile="$INSTALL_PATH/Uninstaller/uninstaller" stage="never"/> </pack> </packs> </installation>
For Microsoft Windows Shorcut, create the following file Win-shortcutSpec.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <shortcuts> <skipIfNotSupported/> <programGroup defaultName="Sketsa $APP-VERSION" location="applications"/> <shortcut name="Sketsa $APP-VERSION" programGroup="yes" desktop="yes" applications="no" startMenu="no" startup="no" target="$INSTALL_PATH\bin\sketsa.exe" commandLine="" description="Sketsa launcher" iconFile="$INSTALL_PATH\sketsa\sketsa.ico" iconIndex="0" initialState="noShow"> </shortcut> <shortcut name="Readme.html" programGroup="yes" desktop="no" applications="no" startMenu="no" startup="no" target="$INSTALL_PATH\readme.html" commandLine="" description="Sketsa Readme"> </shortcut> <shortcut name="Uninstaller" programGroup="yes" desktop="no" applications="no" startMenu="no" startup="no" target="$INSTALL_PATH\Uninstaller\uninstaller.exe" commandLine="" description="Sketsa uninstaller"> </shortcut> </shortcuts>
Finally add custom ant target in your suite build.xml
This target basiclly
- build-zip distribution as specified in Netbeans Harness
- unzip the above build-zip
- create the Izpack Installer from the above
- zip the result again
You may also need the following properties defined in the suite Project Properties
# Custom Properties # NOTE: Please check platform harness to avoid properties name conflict app.title.full=${app.title} SVG Editor app.buildnumber=200712311131 app.version=5.0.4 app.version.dash=5_0_4
Add the following ant target into your suite build.xml
<target name="build-installer" description="Create Installer" depends="clean,build-zip"> <echo message=" "/> <echo message="Setting property and task for installer creation" /> <property name="nbdist.dir" value="dist"/> <property name="nbdist-app.dir" value="${nbdist.dir}/${app.name}"/> <property name="nbdist-app-installer" value="${app.name}-${app.version.dash}.zip"/> <property name="izpack-installer" value="setup.jar"/> <property name="izpack.dir" value="/home/tonny/opt/IzPack"/> <taskdef name="izpack" classpath="${izpack.dir}/lib/compiler.jar" classname="com.izforge.izpack.ant.IzPackTask"/> <echo message=" "/> <echo message="Preparing ...." /> <unzip src="${nbdist.dir}/${app.name}.zip" dest="${nbdist.dir}"/> <copy todir="${nbdist-app.dir}/legal"> <fileset dir="legal"/> </copy> <copy todir="${nbdist-app.dir}/${app.name}"> <fileset dir="installer/icons" /> </copy> <copy file="installer/readme.html" todir="${nbdist-app.dir}"/> <replace file="${nbdist-app.dir}/readme.html"> <replacefilter token="$${app.version}" value="${app.version}" /> </replace> <copy todir="${nbdist-app.dir}"> <fileset dir="installer/izpack" /> </copy> <replace file="${nbdist-app.dir}/izpack-install-script.xml"> <replacefilter token="$APP-NAME" value="${app.title.full}" /> <replacefilter token="$APP-VERSION" value="${app.version}" /> <replacefilter token="$APP-PATH" value="Kiyut/${app.title}-${app.version.dash}" /> </replace> <replace file="${nbdist-app.dir}/Win-shortcutSpec.xml"> <replacefilter token="$APP-VERSION" value="${app.version}" /> </replace> <replace file="${nbdist-app.dir}/etc/${app.name}.conf"> <replacefilter token="/dev" value="/${app.version}" /> <replacefilter token="-J-Xms24m -J-Xmx64m" value="${run.args.extra}" /> </replace> <echo message=" "/> <echo message="Makes the installer using IzPack to ${izpack-installer}"/> <izpack input="${basedir}/${nbdist-app.dir}/izpack-install-script.xml" output="${basedir}/${nbdist-app.dir}/${izpack-installer}" installerType="standard" basedir="${basedir}/${nbdist-app.dir}" izPackDir="${izpack.dir}/"/> <echo message=" "/> <echo message="create the release ${nbdist-app-installer}"/> <zip destfile="${nbdist.dir}/${nbdist-app-installer}"> <zipfileset dir="${nbdist-app.dir}"> <include name="readme.html"/> <include name="setup.exe"/> <include name="${izpack-installer}"/> </zipfileset> <zipfileset dir="${nbdist-app.dir}" filemode="755"> <include name="setup"/> </zipfileset> </zip> <echo message=" "/> <echo message="cleaning and finalizing release" /> <delete dir="${nbdist-app.dir}"/> <echo message=" "/> <echo message="release: ${nbdist-app-installer}" /> </target>
Finally
It is done, just do not forget to test the result










9 Responses to “Deploy Netbeans Platform based Application using IzPack Installer”
By Markus on Jan 2, 2008 | Reply
IZPack is great for Windows and Linux and we use it for our platform application, http://www.nspike.com. I do wish they would include better support for MacOS X too.
By Toni Epple on Jan 4, 2008 | Reply
Hey Tonny, I wrote a tutorial on integrating IzPack with NetBeans on my blog a while ago myself. That reminds me tat I have to try out the openInstaller tutorial by Vadiraj.
Toni
By Tonny Kohar on Jan 4, 2008 | Reply
@Toni Epple
the more tutorial the better
Yup, the OpenInstaller is seem very good options also. There is also Nbi installer from Netbeans
By Tonny Kohar on Jan 4, 2008 | Reply
@Markus
Yes, it would be better if IzPack has support for Mac OSX. However, if your application is based on Netbeans Platform RCP, since Nb 6 there is already ant target for building Mac OSX
By Kevin on Apr 18, 2008 | Reply
What would help when using these instructions as a starting point is a folder layout, i.e. what folders are needed, what files go in what folders etc. For example, you say create izpack-install-script.xml but it’s not clear where you need to create this file until you start digging into the ant script. Describing the folder/file layout explicitly might make it easier for the reader to get up to speed.
By Tonny Kohar on Apr 18, 2008 | Reply
@Kevin
Thanks for the feedback, I just updated the blog entry and add the folder/file structure layout
By Kevin on Apr 18, 2008 | Reply
One problem I had in following this example was with the uninstaller. The IzPack install script seems to assume uninstaller.exe exists, but where has this executable come from?
By Tonny Kohar on Apr 18, 2008 | Reply
@Kevin
The uninstaller.exe is just a simple exe that execute uninstaller.jar. You can replace the uninstaller.exe with uninstaller.jar in the Win-shortcutSpec.xml uninstaller section