您的位置:首页 > 其它

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

2017-09-15 00:00 525 查看
系统环境: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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  IzPack 打包工具