Skip to end of banner
Go to start of banner

IzPack Installer - Tutorial

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

This tutorial is a step by step creation of an IzPack Installer. You will be creating a simple swing based application.

 

Object

Create an IzPack Installer using following tools: IzPack, Ant, Bash for GNU/Linux and Microsoft Windows 7

IzPack on GNU/Linux

Step 1.  - Assumptions

Step 2. - Preparation

  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.

Step 3. - Create A Swing Based Application

  1. Make sure you're in your new created project folder.
  2. Go to the source folder (src).
  3. Create a Java Class (name: HelloWorld).
  4. Paste the source code down below (name: A Simple Swing Based HelloWorld Application) to your new created class.
  5. Compile it.
A Simple Swing Based HelloWorld Application
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("Quit");
       quitButton.setBounds(50, 60, 80, 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);
            }
        });
    }
} 

Step 4. - Create An Ant Script

  1. Highlight your project folder.
  2. Execute the shortkey CTRL+N.
  3. Go to XML folder and choose XML File
  4. Name this XML File (build.xml)
  5. Paste the xml code down below to build.xml
build.xml
<?xml version="1.0"?>
<project name="MyTestProject" 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.

  1. Run the IzPack jar file (java -jar /path/to/IzPack/Jar)
  2. Follow the installation instructions. Remember the directory where the IzPack Installer Framework has been installed (used in tutorial: /home/user/Desktop/IzPack).
  3. Create two directories. The first directory for the IzPack setting file for the creational process and second directory for the created installer.

TODO: Information about the folder structure of the IzPack Installer Framework

To use the IzPack Framework in the HelloWorld project follow next instructions.

Create two more properties in the build.xml. Use the following xml code and import this right after the existing two properties.

New Properties for the build.xml
<property name="install.file" location="/home/user/Desktop/IzPack/install.xml" />
<property name="image.dir" location="/home/user/Desktop/IzPack/images" />

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 paste in the build.xml right after the build target.

The Ant Target for the IzPack
<taskdef name="mkinstaller" 
	classpath="/home/max/Desktop/IzPack/lib/standalone-compiler.jar" 
	classname="com.izforge.izpack.ant.IzPackTask"/>

<target name="mk_installer" depends="build">
	<mkinstaller input="${install.file}" 
		output="/home/max/Desktop/HelloWorld/HelloWorld_installer.jar" 
		basedir="/home/max/Desktop/MYINSTALLER/"/>
</target>

IzPack on Microsoft Windows 7

 

  • No labels