IzPack打包工具 源碼編譯、安裝、使用

系統環境:CentOS 6.8html

本例全部素材下載java

簡介:

IzPack是Java平臺上的開源跨平臺的程序打包工具。採用XML文件進行打包程序的配置。linux

因爲是開源軟件,所以能夠根據須要,自行修改源代碼,以知足具體的需求。git

1.下載IzPack 源碼地址

2.編譯安裝(須要Maven 3和Java)

unzip izpack-master.zip
cd izpack-master/
mvn clean install

/izpack-master/izpack-dist/targetgithub

java -jar izpack-dist-5.1.2-SNAPSHOT.jar

IzPack安裝界面:shell

安裝界面

安裝界面

4.使用IzPack打包

如圖爲咱們使用的測試打包程序(該程序沒有任何功能)。apache

測試程序

以下命令打包windows

/home/sun/IzPack/bin/compile ./Install.XML -b ./TestApp/ -o ./MyTestApp.jar

打包前須要修改Install.XML文件中以下部分的文件地址爲你的實際地址bash

<packs>
    <pack name="TestAppCore" required="yes">
      <description>The core files needed for the application</description>
      <file src="/home/sun/Test/Test/TestApp/start.exe" targetdir="${INSTALL_PATH}" override="true"/>
    </pack>
    
    <pack name="Doc" required="no">
      <description>The Doc files</description>
      <fileset dir="/home/sun/Test/Test/TestApp/Doc" targetdir="${INSTALL_PATH}/Doc" override="true"/>
    </pack>
    
    <pack name="lib" required="no">
      <description>The lib files</description>
      <fileset dir="/home/sun/Test/Test/TestApp/lib" targetdir="${INSTALL_PATH}/lib" override="true"/>
</pack>

打包完成後,便可運行已經打好的安裝程序oracle

java -jar MyTestApp.jar

5.Install.XML文件簡介

<izpack:installation version="5.0"
                     xmlns:izpack="http://izpack.org/schema/installation"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://izpack.org/schema/installation http://izpack.org/schema/5.0/izpack-installation-5.0.xsd">
​
​
  <info>
    <appname>TestApp</appname>
    <appversion>1.0</appversion>
    <appsubpath>TestApp</appsubpath>
    <javaversion>1.6</javaversion>
  </info>
​
  <locale>
    <langpack iso3="eng"/>
    <langpack iso3="chn"/>
  </locale>
​
  <guiprefs width="800" height="600" resizable="no">
    <splash>images/peas_load.gif</splash>
    <laf name="substance">
      <os family="windows" />
      <os family="unix" />
      <param name="variant" value="mist-silver" />
    </laf>
    <laf name="substance">
      <os family="mac" />
      <param name="variant" value="mist-aqua" />
    </laf>
    <modifier key="useHeadingPanel" value="yes" />
  </guiprefs>
​
  <panels>
    <panel classname="TargetPanel"/>
    <panel classname="PacksPanel"/>
    <panel classname="InstallPanel"/>
    <panel classname="FinishPanel"/>
  </panels>
  
  <packs>
    <pack name="TestAppCore" required="yes">
      <description>The core files needed for the application</description>
      <file src="/home/sun/Test/Test/TestApp/start.exe" targetdir="${INSTALL_PATH}" override="true"/>
    </pack>
    
    <pack name="Doc" required="no">
      <description>The Doc files</description>
      <fileset dir="/home/sun/Test/Test/TestApp/Doc" targetdir="${INSTALL_PATH}/Doc" override="true"/>
    </pack>
​
    <pack name="lib" required="no">
      <description>The lib files</description>
      <fileset dir="/home/sun/Test/Test/TestApp/lib" targetdir="${INSTALL_PATH}/lib" override="true"/>
    </pack>
    
  </packs></izpack:installation>

<info> : 基本信息。

<locale>:安裝前的語言選擇列表項目。

</guiprefs>:一些界面配置。

<panels>:安裝界面。安裝程序的界面會根據這部分編寫的順序依次顯示。

<packs>:要打包的程序在這部分進行配置。

附錄:

1.安裝 Apache Maven 官方地址

unzip apache-maven-3.5.0-bin.zip

設置環境變量(臨時):

export PATH=/home/sun/Install/apache-maven-3.5.0/bin:$PATH

設置環境變量(一勞永逸):

修改 /etc/profile

# /etc/profile
​
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
​
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
​
export PATH=/home/sun/Install/apache-maven-3.5.0/bin:$PATH
​
pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac

2.安裝JDK 官方地址

tar zxvf jdk-8u144-linux-x64.tar.gz

設置環境變量

export JAVA_HOME=/home/sun/Install/jdk1.8.0_144/
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

驗證

[sun@localhost ~]$ source /etc/profile
[sun@localhost ~]$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
相關文章
相關標籤/搜索