jar的使用方法介绍

jar的全称:JavaTM Archive (JAR) file,是java存档文件。
用于java 的class等文件压缩打包

 用法:jar {ctxu}[vfm0Mi] [jar-文件] [manifest-文件] [-C 目录] 文件名 ...   

  选项:   

  -c 创建新的存档

  -t 列出存档内容的列表

  -x 展开存档中的命名的(或所有的〕文件

  -u 更新已存在的存档

  -v 生成详细输出到标准输出上

  -f 指定存档文件名

  -m 包含来自标明文件的标明信息

  -0 只存储方式;未用zip压缩格式

  -M 不产生所有项的清单(manifest〕文件

  -i 为指定的jar文件产生索引信息

  -C 改变到指定的目录,并且包含下列文件:  

打包当前目录下的class:
进入当前目录,
输入
jar  -cvf  .jar  Test1.class, Test2.class

打包webapps/myapp为一个war发布包:
进入 webapps/myapp
输入jar  -cvf  myapp.war  *

这里生成的war可以发布到tomcat/webapps或者webshphere


jar基本操作:   

  1. 创建jar文件  


  jar cf jar-file input-file(s)
  c---want to Create a JAR file.
  f---want the output to go to a file rather than to stdout.
        v---Produces verbose(详细的) output. 
  eg:
        1)jar cf myjar.jar query_maintain_insert.htm
  2)jar cvf myjar.jar query_maintain_insert.htm  
       3)jar cvf myjar.jar query_maintain_insert.htm mydirectory
  4)jar cv0f myjar.jar query_maintain_insert.htm mydirectory
  
        0---don't want the JAR file to be compressed.
  5)jar cmf MANIFEST.MF myjar.jar yahh.txt
  m---Used to include manifest information from an existing manifest file.
  
        6)jar cMf MANIFEST.MF myjar.jar yahh.txt
  M---the default manifest file should not be produced.
  7)jar cvf myjar.jar *
  *---create all contents in current directory. 
 

  2. 察看jar文件   


  jar tf jar-file
  t---want to view the Table of contents of the JAR file.
  eg: 1)jar vft yahh.jar
  v---Produces verbose(详细的) output.  


  3. 提取jar文件  


  jar xf jar-file [archived-file(s)]
  x---want to extract files from the JAR archive.
  eg: 1)jar xf yahh.jar yahh.txt(仅提取文件yahh.txt)
  2)jar xf yahh.jar alex/yahhalex.txt(仅提取目录alex下的文件yahhalex.txt)  

  3)jar xf yahh.jar(提取该jar包中的所有文件或目录)  

 

  4. 修改Manifest文件  


  jar cmf manifest-addition jar-file input-file(s)
  m---Used to include manifest information from an existing manifest file.  


  5. 更新jar文件  


  jar uf jar-file input-file(s)
  u---want to update an existing JAR file.  


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值