展开全部
建议使用ANT打包工具,下载地址:http://apache.justdn.org/ant/binaries/apache-ant-1.6.5-bin.zip
此工具用java编写,跨平台,能实现很多功能:编译、打包、运行、文件操作、62616964757a686964616fe4b893e5b19e31333231633133数据库操作、自定义任务等。
主要使用方法:在工程目录下编写build.xml配置文件,然后运行ant即可:
#ant
或
#java -jar ant.jar
下面给你提供一个例子,是jakarta-oro-2.0.8的包的build.xml
property="AnakiaTask.present"/>
description="Prints error message for prepare target."
unless="AnakiaTask.present">
AnakiaTask is not present! Please check to make sure that
velocity.jar is in your classpath.
description="Compiles the library classes only.">
destdir="${build.dest}"
excludes="examples/**,tools/**"
debug="${debug}"
deprecation="${deprecation}"
optimize="${optimize}"/>
description="Compiles the example classes.">
destdir="${build.dest}"
includes="examples/**"
debug="${debug}"
deprecation="${deprecation}"
optimize="${optimize}"/>
description="Compiles the tool classes.">
destdir="${build.dest}"
includes="tools/**"
debug="${debug}"
deprecation="${deprecation}"
optimize="${optimize}"/>
description="Compiles and runs the unit tests.">
destdir="${build.tests}"
debug="${debug}"
deprecation="${deprecation}"
optimize="${optimize}"/>
basedir="${build.dest}"
includes="org/**,META-INF/**"
excludes="**/package.html,**/overview.html">
value="Jakarta ORO" />
value="${version}" />
value="Apache Software Foundation" />
value="org.apache.oro" />
value="${version} ${DATE}" />
value="Apache Software Foundation" />
description="Creates the API documentation.">
sourcepath="${build.src}"
destdir="${javadoc.destdir}"
overview="${build.src}/org/apache/oro/overview.html"
author="true"
version="true"
windowtitle="${name} ${version} API"
doctitle="${name} ${version} API"
bottom="Copyright © ${year} Apache Software Foundation. All Rights Reserved.">
token="{@docroot}" value="."/>
token="@version@" value="${version}"/>
description="Creates the project web pages and documentation."
if="AnakiaTask.present">
extension=".html" style="./site.vsl"
projectFile="stylesheets/project.xml"
excludes="**/stylesheets/** manual/** empty.xml"
includes="**/*.xml"
lastModifiedCheck="true"
templatePath="${jakarta-site2.dir}/xdocs/stylesheets">
description="Creates a distribution directory tree.">
tofile="${final.dir}/build.properties"/>
tofile="${final.dir}/CONTRIBUTORS"/>
description="Packages the distribution as a zip file.">
includes="**/${final.name}/**" excludes="**/.cvsignore"/>
description="Packages the distribution as a gzipped tar file.">
basedir="${top.dir}" excludes="**/**">
description="Removes generated artifacts from source tree.">
build.xml文件的编写可参见ant发行版中的使用文档
你也可以自己编写脚本打包,使用jdk发行版中的jar命令,例如:
#jar cmf myManifestFile myFile.jar *.class
注意还需要自己编写MANIFEST.MF文件配置包属性。具体可以参见javadoc
当然还可以使用集成开发环境提供的打包工具,如JBuilder提供打包工具,但这样程序的移植性不强,建议不要使用,就使用ant比较好。
本回答由提问者推荐
已赞过
已踩过<
你对这个回答的评价是?
评论
收起