IzPack打包工具 源码编译、安装、使用

系统环境:CentOS 6.8

本例所有素材下载

简介:

IzPack是Java平台上的开源跨平台的程序打包工具。采用XML文件进行打包程序的配置。

由于是开源软件,因此可以根据需要,自行修改源代码,以满足具体的需求。

1.下载IzPack 源码地址
2.编译安装(需要Maven 3和Java)
unzip izpack-master.zip
cd izpack-master/
mvn clean install

/izpack-master/izpack-dist/target

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

IzPack安装界面:

安装界面

安装界面

4.使用IzPack打包

如图为我们使用的测试打包程序(该程序没有任何功能)。

测试程序

如下命令打包

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

打包前需要修改Install.XML文件中如下部分的文件地址为你的实际地址

<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>

打包完成后,即可运行已经打好的安装程序

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)

 

转载于:https://my.oschina.net/u/3618133/blog/1537948

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值