Friday, October 24, 2008

Creating shortcuts with IzPack

IzPack is an excellent tool for deploying your software. During the wizard installation process you can create some shortcuts (on Windows or Linux). To enable shortcuts there are a few changes required in your install.xml, then the actual shortcut information is contained in seperate xml files.

First edit your install.xml by adding:
<panels>
...(other panels)...
<panel classname="ShortcutPanel"/>
...(other panels)...
</panels>

(Required for Windows only)
<native
type="izpack" name="ShellLink.dll"/>


This ensures the shortcut panel will be present in your installer and the native libraries required for Windows are included. Next specify two shortcuts, one to your application (so a jar) and one to a local HTML file (your documentation). You can alter the file names, as long as you tell install.xml where to find the files.

For Windows, shortcutSpec.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<shortcuts>
<skipIfNotSupported/>
<programGroup defaultName="MyApp"
location="applications"/>

<shortcut
name="wekautils"
target="$INSTALL_PATH\MyApp.jar"
description="Launch app"
workingDirectory="$INSTALL_PATH"
iconFile="$INSTALL_PATH\images\logo.ico"
initialState="normal"
programGroup="yes"
desktop="yes"
applications="no"
startMenu="no"
startup="no">


<createForPack name="Core"/>
</shortcut>

<shortcut
name="Documentation"
target="$INSTALL_PATH\doc\index.html"
description="Launch documentation"
initialState="normal"
programGroup="yes"
desktop="no"
applications="no"
startMenu="no"
startup="no">

<createForPack name="Core"/>
</shortcut>


</shortcuts>
and for Linux, slightly altered format, Unix_shortcutSpec.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<shortcuts>
<skipIfNotSupported/>
<programGroup defaultName="MyApp"
location="applications"/>

<shortcut
name="MyApp"
target="/usr/bin/java"
commandLine="-jar $INSTALL_PATH/MyApp.jar"
description="Launch MyApp"
iconFile="$INSTALL_PATH/images/MyApp.png"
workingDirectory="$INSTALL_PATH"
initialState="normal"
programGroup="yes"
desktop="no"
applications="no"
startMenu="no"
startup="no"
type="Application"
terminal="true"
encoding="UTF-8">


<createForPack name="Core"/>
</shortcut>

<shortcut
name="Documentation"
description="Launch documentation"
initialState="normal"
programGroup="yes"
desktop="no"
applications="no"
startMenu="no"
startup="no"
type="link"
url="$INSTALL_PATH/doc/index.html"
terminal="false"
encoding="UTF-8">


<createForPack name="Core"/>
</shortcut>

</shortcuts>

See the IzPack website for further documentation.