java build 打包_java如何打包

展开全部

建议使用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"

header="Jakarta ORO"

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比较好。

本回答由提问者推荐

2Q==

已赞过

已踩过<

你对这个回答的评价是?

评论

收起

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值