现在我们接着玩上次的试验结果,双击生成的install.jar运行安装,如下图:
图lzPack1-1
下一步如图:(你发现和lzPack本身的安装过程和界面是一样的,不过也已经够漂亮了,是吧)(以后都是下一步的图)
图lzPack1-2
图lzPack1-3
图lzPack1-4
图lzPack1-5
图lzPack1-6
图lzPack1-7
图lzPack1-8
点击Done完成安装
看看我们sample的结构(即要安装的软件)
图lzPack1-9
看看安装好的文件结构
图lzPack1-10
少了一个文件listener,多了一个文件uninstaller,进入uninstaller双击uninstaller.jar就看到卸载界面了(超简单的界面,就不贴了)。我们在回头看看那个配置文件install.xml,如下:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
- <!--
A sample installation file.
Use it as a base for your own installers :-)
To compile it :
- go in the bin directory where you installed IzPack
- call "compile ../sample/install.xml -b ../sample"
-->
- <installation version="1.0">
- <!--
The info section.
The meaning of the tags should be natural ...
-->
- <info>
<appname>Sample Installation</appname>
<appversion>1.4 beta 666</appversion>
- <authors>
<author name="JPz" email="jpz@superman.org" />
<author name="Hidden Man" email="hidden@hisdomain.com" />
</authors>
<url>http://www.anotherworld-inspace-website.net/</url>
</info>
- <!--
The gui preferences indication.
Sets the installer window to 640x480. It will not be able to change the size.
-->
<guiprefs width="640" height="480" resizable="no" />
- <!--
The locale section.
Asks here to include the English and French langpacks.
-->
- <locale>
<langpack iso3="eng" />
<langpack iso3="fra" />
</locale>
- <!--
The resources section.
The ids must be these ones if you want to use the LicencePanel and/or the InfoPanel.
-->
- <resources>
<res id="LicencePanel.licence" src="Licence.txt" />
<res id="InfoPanel.info" src="Readme.txt" />
</resources>
- <!--
The panels section.
We indicate here which panels we want to use. The order will be respected.
-->
- <panels>
<panel classname="HelloPanel" />
<panel classname="InfoPanel" />
<panel classname="LicencePanel" />
<panel classname="TargetPanel" />
<panel classname="PacksPanel" />
<panel classname="InstallPanel" />
<panel classname="FinishPanel" />
</panels>
- <!--
The packs section.
We specify here our packs.
-->
- <packs>
- <pack name="Base" required="yes">
<description>The base files</description>
<file src="Readme.txt" targetdir="$INSTALL_PATH" />
<file src="Licence.txt" targetdir="$INSTALL_PATH" />
<file src="script.bat" targetdir="$INSTALL_PATH" />
<parsable targetfile="$INSTALL_PATH/script.bat" />
- <!--
The file will be parsed
-->
</pack>
- <pack name="Docs" required="no">
<description>The documentation</description>
<file src="doc" targetdir="$INSTALL_PATH" />
- <!--
Reccursive adding
-->
</pack>
- <pack name="Sources" required="no">
<description>The sources</description>
<file src="src" targetdir="$INSTALL_PATH" />
</pack>
</packs>
</installation>
我算它是七段,第一段
<installation version="1.0">
声明安装的版本
第二段
<info>
<appname>Sample Installation</appname>
<appversion>1.4 beta 666</appversion>
- <authors>
<author name="JPz" email="jpz@superman.org" />
<author name="Hidden Man" email="hidden@hisdomain.com" />
</authors>
<url>http://www.anotherworld-inspace-website.net/</url>
</info>
声明软件的基本信息:名称、版本、各个作者和联系方式、公司主页。对应图lzPack1-2。
第三段
<guiprefs width="640" height="480" resizable="no" />
设置安装导航的宽高等属性。
第四段
<locale>
<langpack iso3="eng" />
<langpack iso3="fra" />
</locale>
语言选择,对应图图lzPack1-1。
第五段
<resources>
<res id="LicencePanel.licence" src="Licence.txt" />
<res id="InfoPanel.info" src="Readme.txt" />
</resources>
提供两个资源给客户阅读,对应两个界面,图lzPack1-3和lzPack1-4。分别为软件说明和基本条款。
第六段
<panels>
<panel classname="HelloPanel" />
<panel classname="InfoPanel" />
<panel classname="LicencePanel" />
<panel classname="TargetPanel" />
<panel classname="PacksPanel" />
<panel classname="InstallPanel" />
<panel classname="FinishPanel" />
</panels>
说明顺序下来都经过那些界面。
第七段
<packs>
- <pack name="Base" required="yes">
<description>The base files</description>
<file src="Readme.txt" targetdir="$INSTALL_PATH" />
<file src="Licence.txt" targetdir="$INSTALL_PATH" />
<file src="script.bat" targetdir="$INSTALL_PATH" />
<parsable targetfile="$INSTALL_PATH/script.bat" />
- <!--
The file will be parsed
-->
</pack>
- <pack name="Docs" required="no">
<description>The documentation</description>
<file src="doc" targetdir="$INSTALL_PATH" />
- <!--
Reccursive adding
-->
</pack>
- <pack name="Sources" required="no">
<description>The sources</description>
<file src="src" targetdir="$INSTALL_PATH" />
</pack>
</packs>
提供了要复制的文件夹结构,由<packs>标签包括
共有三个包,每个包由<pack>标签标识, name=”base” 的包为基本包,包括所有文件和文件夹的文件夹,其下包括三个文件。$INSTALL_PATH即安装路径,由用户给出
包Docs 是文件夹doc。
<file >元素标明文件或文件夹,src属性为文件或文件夹名,targetdir属性为要放到的路径
包Sources是文件夹src。
整个文件结构和关系就由最后这一段来阐释。
另外,包<pack>还可以有其他的用途,下一节是个较实用的实例,你会看到它的用途,要不我们打的包都和izpack一样光秃秃的,没快捷键,没环境变量,在实践中我们慢慢发现光明,原来有趣的东西等着我们去探索。
一种更好的态度,更好的学习、思维方式。它会是网络极佳的生存方式,你喜欢就对。