Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

IzPack on GNU/Linux

Step 1.   - Assumptions

...

  1. Start Eclipse and create a new Java Project in it.
    1. File -> New -> Java Project.
    2. Name your project (for example: IzPackInstaller).
    3. JRE Settings in Eclipse should be intakt.

...

Code Block
themeRDark
languagejava
titleA Simple Swing Based HelloWorld Application
linenumberstrue
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class HelloWorld extends JFrame {

    public HelloWorld() {
        initUI();
    }

    public final void initUI() {

       JPanel panel = new JPanel();
       getContentPane().add(panel);

       panel.setLayout(null);

       JButton quitButton = new JButton("QuitHello World");
       quitButton.setBounds(50, 60, 80120, 30);
       quitButton.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent event) {
               System.exit(0);
          }
       });

       panel.add(quitButton);

       setTitle("Quit button");
       setSize(300, 200);
       setLocationRelativeTo(null);
       setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                HelloWorld ex = new HelloWorld();
                ex.setVisible(true);
            }
        });
    }
} 

...

Code Block
themeRDark
languagehtml/xml
titlebuild.xml
linenumberstrue
<?xml version="1.0"?>
<project name="MyTestProjectHelloWorld" default="build" basedir=".">
  
  <property name="src.dir" location="src" />
  <property name="build.dir" location="bin" />

  <target name="clean">
    <delete dir="${build.dir}" />
  </target>

  <target name="makedir">
    <mkdir dir="${build.dir}" />
  </target>

  <target name="build" depends="clean, makedir">
    <javac srcdir="${src.dir}" destdir="${build.dir}"/>
  </target>

</project> 

This build.xml is a standard build ant script. Right now it consists of two properties (src.dir, build.dir) and three targets (clean, makedir, build). For the future steps import this ant script to your Ant View in Eclipse.

Step 5. - Import IzPack

In this step the recently downloaded IzPack 4.3.5 Jar File will be imported to the project.

...

Code Block
themeRDark
languagehtml/xml
titleContent for install.xml
linenumberstrue
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>

<!-- 
    A sample installation file.
    Use it as a base for your own
installers
:-)
    
    To compile it :
    - go in the bin directory where you installed IzPack
    - call "compile ../sample/install.xml -b ../sample"
-->

<installation version="1.0">
    <!--<info>
        <appname>Hello The info section.
        The meaning of the tags should be natural ...
    -->
    <info>
        <appname>NovaTec inspectIT<World Application</appname>
        <appversion>1.4<0</appversion>
        <authors>
            <author name="NovaTecYour Givenname and Lastname" email="info@novatecgivenname.lastname@hello-gmbhworld.org"/>
        </authors>
        <url>http://www.novatechello-gmbhworld.de/</url>
    </info>

    <!-- 
        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="yes"/>

    <!-- 
        The locale section.
        Asks here to include the English and French langpacks.
 
 
-->     <locale>
        <langpack iso3="eng"/>
        <langpack iso3="deu"/>

   </locale>

    <!-- 
        The resources section.
        The ids must be these ones if you want to use
the
LicencePanel and/or the InfoPanel.
    -->
    <resources>
		<res id="installer.langsel.img" src="inspectithelloworld_logoimage1.png" />
		<res id="Installer.image" src="novatechelloworld_logo2image2.png" />
    	    <res id="LicencePanel.licence" src="Licence.txt"/>
    	    <res id="InfoPanel.info" src="Readme.txt"/>
	<res src="shortcutSpec.xml" id="Win_shortcutSpec.xml"/>
	<res src="Unix_shortcutSpec.xml" id="Unix_shortcutSpec.xml"/>
    </resources>

    <!-- 
        The
panels
section.         We indicate here which panels we want to use. The order will be respected.
    -->
    <panels>
        <panel classname="HelloPanel"/>
        <panel classname="InfoPanel"/>
        <panel classname="LicencePanel"/>
        <panel classname="TargetPanel"/>
        <panel classname="PacksPanel"/>
        <panel classname="InstallPanel"/>
	<panel
classname="ShortcutPanel"/>         <panel classname="FinishPanel"/>

   </panels>

<!--	 	(Required for Windows<packs>
only)
	<native type="izpack" name="ShellLink.dll"/>
-->
    <!-- 
        The packs section.
        We specify here our packs.
    -->
    <packs>
	<pack name="InspectIT" required="yes">
			<description>inspectIT files<<description>Hello World Application Runnables</description>
			<file src="/home/maxuser/workspace/MyTEstProjectIzPackInstaller/bin/MyTestClassHelloWorld.class" targetdir="$INSTALL_PATH"/>
			<file src="/home/maxuser/workspace/MyTEstProjectIzPackInstaller/bin/MyTestClass$1HelloWorld$1.class" targetdir="$INSTALL_PATH"/>
			<file src="/home/maxuser/workspace/MyTEstProjectIzPackInstaller/bin/MyTestClass$2HelloWorld$2.class" targetdir="$INSTALL_PATH"/>
		</pack>
    </packs>

</installation>

TODO: Explain install.xml

Info
iconfalse
titleCode Explanation
  • This is a small explanation of the install.xml file. Tag info defines the meta data of the installer. This information will be placed on the first panel (HelloPanel) of the installer (if the gui version of the installer was executed). The underlying tags are self explanatory.
  • The guiprefs tag defines the size in width and height and resizability of all the gui dialogs
  • The locale tag specifies the language of the generated intaller text.
  • The resources tag defines all resources such an image or a text file to be imported to the installer.
  • The panels tag defines which panels are shown by executing the installer. In other words these are the window dialogs that are shown.
  • The packs tag defines the content to be installed by the installer.

 

Next lines of xml code are the hearth of the creation of an installer with aid of IzPack Framework. Paste the xml code down below in the build.xml right after the build target.

Code Block
themeRDark
languagehtml/xml
titleThe Ant Target for the IzPack
linenumberstrue
<taskdef name="mkinstaller" 
	classpath="/home/user/Desktop/IzPack/lib/standalone-compiler.jar" 
	classname="com.izforge.izpack.ant.IzPackTask"/>

<target name="mk_installer" depends="build">
	<mkinstaller input="${install.file}" 
		output="/home/user/Desktop/HelloWorld/HelloWorld_installer.jar" 
		basedir="/home/user/Desktop/Files4Installer/"/>
</target>
Info
iconfalse
titleCode explanationExplanation
  • This piece of code defines a taskdef and a new target named mkinstaller and mk_installer respectively. The attribute classpath of taskdef takes as value the path to the standalone-compiler of IzPack. The standalone-compiler is a jar file and it is located in the lib directory in the installation directory of IzPack (used in tutorial: /home/user/Desktop/IzPack). The value of the attribute classname should be "com.izforge.izpack.ant.IzPackTask".
  • The target mk_installer executes the previous defined taskdef mkinstaller and build the installer of HelloWorld application. The input attribute takes the install.xml and the output attribute is the directory where the ready-to-run installer file will be placed (used in tutorial: /home/user/Desktop/HelloWorld). Notice the dependency for mk_installer.

...

If you reached this section and done all the pastings and installations in the right order then right now you can build your first installer containing the compiled source code of the HelloWorld application. In the Ant View of Eclipse you can find the new created target named mk_installer and by executing it following steps should be done one by one: source code compilation -> taking compiled source code and creating an installer by using a defined directory (used in tutorial: /home/user/Desktop/Files4Installer) -> placing the created jar file in specified directory (used in tutorial: /home/user/Desktop/HelloWorld).

IzPack on Microsoft Windows 7 (TODO)