Using Izpack to create an installer with Ant

Document created by jstevens1 on Mar 4, 2009Last modified by jstevens1 on Mar 5, 2009
Version 6Show Document
  • View in full screen mode

I have been compiling custom spark versions for about two years to use at work. We have a large windows network and the worst part has always been creating an exe or msi to push the new versions out to our users. I have tried using various open source install builders and trial versions of commercial builders with mixed success. None of the commercial products I have tried have been easy or automatable enough to get me to fork out the usually hundreds of dollars they seem to think these products are worth. This has often caused me to procrastinate about adding features I might want or even just keeping up to date with the latest version.


Recently we had some major changes and I just could not put off compiling a new version anymore. I downloaded the latest source from SVN and made the changes I wanted and compiled. Easy as pie, it only took about four hours for everything, including updating my version of ant and getting the latest java sdk.


Then It was time to figure out what to do about the installer. I came to the forums and couldnt find any new ideas, except for this post from cstux about Izpack which I had never heard of. His patch is apparently for Eclipse which I have never used so at first I was a little stumped. But after some digging around and several dead ends I was finally able to use his patch and his tip about "ant installer.izpack" to finally compile and get an installer in one easy step.


This is still a work in progress so any tips or suggestions are greatly appreciated.


Step 1. Download and Install izpack ( ) and launch4j ( )


Step 2. Open up your build.xml file and make the following changes:


Under the rest of the property tags near the top of the file add this line changing "path/to/Izpack" to match your system. In my case it was "c:\\Program Files\\izpack":


<property name="installer.izpack.dir" value="/path/to/IzPack/"/>

<property name="installer.launch4j.dir" value="c:\\Program Files\\Launch4j" />


Then directly under the comment where the installers start I added :


<target name="installer.izpack" depends="jar" description="build release a izpack installer">
        <mkdir dir="${basedir}/installer/" />
        <taskdef name="IzPack"
        <IzPack input="${basedir}/build/installer/spark-izpack.xml" output="${basedir}/installer/spark-installer.jar"
                installerType="standard" izPackDir="${installer.izpack.dir}" basedir="${basedir}"/>
        <taskdef name="launch4j"
                classpath="${installer.launch4j.dir}/launch4j.jar:${installer.launch4j.dir}/lib /xstream.jar"
        <launch4j configFile="${basedir}/build/installer/spark.xml" tmpdir="c:\tmp" />


Notice the c:\tmp, I got an error that said the temp director path can't ave spaces in it


Step 3.


Create a file under build/installer called spark-izpack.xml and paste this into it, be sure to change the references to spark and

the ignite realtime website to match your version:


<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<installation version="1.0">
    <guiprefs width="640" height="480" resizable="no" />

     <native type="izpack" name="ShellLink.dll"/>
          <langpack iso3="eng"/>
        <langpack iso3="fra"/>
        <langpack iso3="deu"/>
        <langpack iso3="ita"/>
        <langpack iso3="jpn"/>
        <langpack iso3="spa"/>
        <langpack iso3="dan"/>
        <langpack iso3="ell"/>
        <langpack iso3="cat"/>
        <langpack iso3="ned"/>
        <langpack iso3="fin"/>
        <langpack iso3="swe"/>
        <langpack iso3="por"/>
        <langpack iso3="pol"/>
        <langpack iso3="rus"/>
        <langpack iso3="ukr"/>
        <langpack iso3="hun"/>
        <langpack iso3="svk"/>
        <langpack iso3="rom"/>
        <langpack iso3="mys"/>
        <langpack iso3="nor"/>
        <langpack iso3="chn"/>
        <langpack iso3="scg"/>
        <langpack iso3="cze"/>
        <langpack iso3="kor"/>
        <langpack iso3="glg"/>
        <res src="build/installer/izpack/shortcutSpec.xml" id="shortcutSpec.xml"/>
        <panel classname="TargetPanel" />
        <panel classname="PacksPanel" />
        <panel classname="InstallPanel" />
        <panel classname="ShortcutPanel" />
        <panel classname="FinishPanel" />
        <pack name="Spark" required="yes">
            <description>XMPP Client</description>
            <file src="target/build/bin"        targetdir="$INSTALL_PATH"/>
            <file src="target/build/lib"        targetdir="$INSTALL_PATH"/>
            <file src="target/build/logs"        targetdir="$INSTALL_PATH"/>
            <file src="target/build/plugins"    targetdir="$INSTALL_PATH"/>
            <file src="target/build/resources"    targetdir="$INSTALL_PATH"/>
            <file src="target/build/xtra"        targetdir="$INSTALL_PATH"/>
            <executable targetfile="$INSTALL_PATH/bin/" />
            <executable targetfile="$INSTALL_PATH/bin/startup.bat" />


You can customize this file a lot and there is very good documentation on the Izpack website. For instance if you

remove all of the languages under locale except the one you want then the user will not see the language selector.


Since I am going for as automated an install as possible I kept mine pretty brief and simple.


Step 4:



Create a folder in build/installer called izpack


In that folder create a new file called shortcutSpec.xml and paste the following into it:


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <programGroup defaultName="Spark" location="applications"/>


        <createForPack name="Spark"/>


            name="Spark-@ver@ Uninstaller"
            description="This uninstalls Spark @build.number@">
        <createForPack name="Spark"/>


This lets you control where shortcuts will be places and what kind of Icons to display. I honestly haven't messed with this too much yet

but it seems to be pretty easy to figure out and I will add more if I find something interesting.


Step 5:


Create a file called spark.xml in build/installer and paste in the following:


  <downloadUrl>    </downloadUrl>
  <var>-Dappdir=&quot;&quot; </var>
    <copyright>Your Company Inc.</copyright>
    <companyName>Your Company</companyName>
    <internalName>Chat Client</internalName>
    <startupErr>An error occurred while starting the application.</startupErr>
    <bundledJreErr>This application was configured to use a bundled Java Runtime Environment but the runtime is missing or corrupted.</bundledJreErr>
    <jreVersionErr>This application requires a Java Runtime Environment.\nAt least version</jreVersionErr>
    <launcherErr>The registry refers to a nonexistent Java Runtime Environment installation or the runtime is corrupted.</launcherErr>
    <instanceAlreadyExistsMsg>An application instance is already running.</instanceAlreadyExistsMsg>



Step 6:


To compile run "ant installer.izpack" in the build directory. This will create your regular target directory and a new directory called installer. The installer.jar file will be in there. Its very fast so if you mess up and want to recompile until you get it right it is no big deal.




If anyone has any advice on making this document more understandable please let me know that as well.