系统环境:CentOS 6.8html
本例全部素材下载java
IzPack是Java平台上的开源跨平台的程序打包工具。采用XML文件进行打包程序的配置。linux
因为是开源软件,所以能够根据须要,自行修改源代码,以知足具体的需求。git
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
如图为咱们使用的测试打包程序(该程序没有任何功能)。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
<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)