1.帮助文档

[root@node1 java]# jar

Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...

Options:

-c create new archive

-t list table of contents for archive

-x extract named (or all) files from archive

-u update existing archive

-v generate verbose output on standard output

-f specify archive file name

-m include manifest information from specified manifest file

-n perform Pack200 normalization after creating a new archive

-e specify application entry point for stand-alone application

bundled into an executable jar file

-0 store only; use no ZIP compression

-P preserve leading '/' (absolute path) and ".." (parent directory) components from file names

-M do not create a manifest file for the entries

-i generate index information for the specified jar files

-C change to the specified directory and include the following file

If any file is a directory then it is processed recursively.

The manifest file name, the archive file name and the entry point name are

specified in the same order as the 'm', 'f' and 'e' flags.

Example 1: to archive two class files into an archive called classes.jar:

jar cvf classes.jar Foo.class Bar.class

Example 2: use an existing manifest file 'mymanifest' and archive all the

files in the foo/ directory into 'classes.jar':

jar cvfm classes.jar mymanifest -C foo/ .

1.1 案例演示

Example 1:将两个class文件归档到名为classes.jar的归档文档中

#切换到testjar目录

cd /opt/testjar

#创建连个class文件

touch Foo.class Bar.class

jar -cvf classes.jar Foo.class Bar.class

Example 2: 使用现有的清单文件’mymanifest’并将/foo目录中的所有文件存档到“classes.jar”中

#创建一个空的清单文件

touch mymanifest

#创建foo文件夹

mkdir foo

#将文件存放到foo目录下

#执行归档操作

jar cvfm classes.jar mymanifest -C foo/ .

1.2 列出jar包中的文件清单

jar -tf classes.jar

1.3 添加新文件到指定jar包中

创建a.txt文件,文件内容为‘寻找手艺人’

[root@node1 testjar]# cat>>a.txt<> 寻找手艺人

> EOF

将a.txt更新到classes.jar中

jar -uf classes.jar a.txt

1.4 提取出内部jar包的指定文件

从classes.jar中提取a.txt文件

jar -xf classes.jar a.txt

提取后修改a.txt文件内容

vim a.txt

1.5 更新修改后的文件到内部jar包.(存在覆盖,不存在就新增)

jar -uf classes.jar a.txt

1.6 更新内部jar包到jar文件

把mysql-connector-jar.jar归档到classes.jar归档文件中

jar -uf classes.jar mysql-connector-java.jar

或者通过vim查看是否已更改

vim classes.jar

输出以下内容:

" zip.vim version v27

" Browsing zipfile /opt/testjar/classes.jar

" Select a file with cursor and press ENTER

META-INF/

Foo.class

Bar.class

mysql-connector-java.jar

2.解压jar包,修改后重新打包jar

解压classes.jar到/aaa目录下

mkdir aaa

unzip classes.jar -d ./aaa

在/aaa目录中更新a.txt内容,并重新打包为jar文件

jar -cfM0 new-classes.jar ./*

linux提取最新修改文件下载,linux 解压修改jar包内容并重新打包jar相关推荐

  1. 修改jar包文件,重新打包jar

    一.网上搜到的下列替换方案都不行: 1.直接用WinRAR拖拽替换jar包内文件 失败,报错:压缩文件已损坏. 我以前替换成功过,但是启动的时候报错.这种方式可能会伤害到jar包的一些标识. 只适合z ...

  2. Linux下各种压缩文件的解压方法

    对于刚刚接触Linux 的人来说,一定会给Linux下一大堆各式各样的文件名给搞晕.别个不说,单单就压缩文件为例,我们知道在Windows 下最常见的压缩文件就只有两种,一是,zip,另一个是.rar ...

  3. Linux下7za对rar文件解压失败问题

    7za对rar文件解压失败问题 问题原因: 7za不支持对rar的解压,7z才支持 解决方法: 1).安装包安装 去网站 http://sourceforge.net/projects/p7zip/f ...

  4. linux中tar.xz文件如何解压

    XZ压缩最新压缩率之王 xz这个压缩可能很多都很陌生,不过您可知道xz是绝大数Linux默认就带的一个压缩工具. 之前xz使用一直很少,所以几乎没有什么提起. xz压缩文件方法或命令 xz -z 要压 ...

  5. 【Linux命令】tar 压缩、解压

    Linux 命令 第一章 Linux 命令 - tar常用压缩.解压命令 文章目录 Linux 命令 前言 一.linux 压缩.解压命令 二.使用步骤 1.压缩 2.解压 3.查看压缩包内容 4.t ...

  6. linux tar.xz 解压命令,Linux下.tar.xz文件的解压教程详解

    前言 对于xz这个压缩相信很多人陌生,但xz是绝大数linux默认就带的一个压缩工具,xz格式比7z还要小. 最近在下载某个源码包的时候遇到的这种压缩格式,乘此机会分享一下xz的压缩与解压方法. 安装 ...

  7. Linux世界的三种压缩解压方式,zip/unzip方式压缩解压、tar方式压缩解压、jar方式压缩解压暨shopt extglob反选示例

    Linux世界的三种压缩解压方式,zip/unzip方式压缩解压.tar方式压缩解压.jar方式压缩解压暨shopt extglob反选示例 zip/unzip方式.tar方式压缩解压是Linux中的 ...

  8. Linux下文件的压缩与解压

    1. 文件压缩 (1)将file1 压缩为file1.tar tar -cvf file1.tar file1 (2)将file1文件压缩为file1.tar.gz tar -czf file1.ta ...

  9. Ubuntu(Linux)下常用的压缩与解压指令合集

    简介 在ubuntu使用过程中,常常会遇到文件解压和压缩的操作,然而压缩的种类又那么多,参数也不少,常常记不住,这里归纳总结一下. .tar 文件 必须的参数:(3个参数不能共存) -c :创建压缩文 ...

最新文章

  1. Python中if语句练习题
  2. redux 和 react-redux 部分源码阅读
  3. Linux 备份系统重要服务的配置文件脚本
  4. nanopi如何与虚拟机连接起来
  5. asp.net C# 实现上传Excel文件导入数据到SQL Server 数据库
  6. django-获取用户数据小结-编辑中
  7. 学完这份风控入门秘籍,再卷也不怕~
  8. 关于Visual Studio .NET 2010最近的发布情况
  9. js页面跳转与url获取
  10. 找不到或无法加载主类什么意思(找不到或无法加载主类)
  11. P1067 多项式输出 【模拟】
  12. 期货反向对冲核心思维跟单策略
  13. 计算机桌面图标乱码,电脑软件上的文字变乱码怎么办?怎么修复?
  14. Vue+Element表格动态列+表格分页
  15. #触摸一体机##五指息屏#
  16. Linux之父-林纳斯 配置命令基操
  17. 如何在鼠标右键菜单中添加自定义菜单?工效率提升一倍
  18. Github每日精选(第75期):colly 爬取网站所有的数据
  19. vcredist x86 安装失败 出现1935错误 解决方法
  20. 人生苦短_“人生苦短,去日苦多”出自哪里?完整的是什么?

热门文章

  1. SpringCloud Getway
  2. 单模多模还傻傻分不清楚?关于光模块介绍,看这一篇就够啦!
  3. mos管的rc吸收电路计算_RC吸收计算应用.doc
  4. oracle ppt讲义,oracle课件.ppt
  5. vscode默认输出到调试控制台
  6. android手机华为p10,谁是运行速度最快的安卓手机?华为P10
  7. 第十六届D2大会(I)
  8. Spring的AOP(一):什么是AOP
  9. word中图片为嵌入式格式时显示不全_word中图片设置嵌入式后无法显示完整的解决方案(转)...
  10. Web版和客户端哪种SQL工具更好?ChatGPT有话要说