解压后还原jar包

解压后还原jar包

记一次 jar 包还原

JAR 文件就是 Java Archive ( Java 档案文件),它是 Java 的一种文档格式。 JAR 文件非常类似 ZIP 文件
准确的说,它就是 ZIP 文件,所以叫它文件包。JAR 文件与 ZIP 文件唯一的区别就是在 JAR 文件的内容中,多出了一个META-INF/MANIFEST.MF 文件,这个文件是在生成 JAR 文件的时候自动创建的 (也可以自行创建)

jar包还原

Soring boot 项目jar包解压之后 修改文件之后 在不依靠开发工具的情况下重新压缩jar包 打包命令如下:

jar -cvf0M xxx.jar BOOT-INF/ META-INF/ org/

jar命令参数
[admin@custmer-development-d ~]$ jar help
Illegal option: h
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/ .

用法:jar {ctxui} [vfmn0PMe] [jar文件] [清单文件] [入口点] [-C目录]文件...
选项:
    -c创建新档案
    -t列出要归档的目录
    -x从存档中提取命名(或所有)文件
    -u更新现有档案
    -v在标准输出上生成详细输出
    -f指定归档文件名
    -m包含来自指定清单文件的清单信息
    -n在创建新存档后执行Pack200规范化
    -e指定独立应用程序的应用程序入口点
        捆绑到可执行的jar文件中
    -0只存储;不使用ZIP压缩
    -P从文件名保留前导的“ /”(绝对路径)和“ ..”(父目录)组件
    -M不为条目创建清单文件
    -i为指定的jar文件生成索引信息
    -C更改为指定目录并包含以下文件
如果任何文件是目录,则将对其进行递归处理。
清单文件名称,归档文件名称和入口点名称为
以与“ m”,“ f”和“ e”标志相同的顺序指定。

示例1:将两个类文件归档到名为classes.jar的归档文件中:
       jar cvf classes.jar Foo.class Bar.class
示例2:使用现有清单文件“ mymanifest”并将所有
           foo /目录中的文件放入“ classes.jar”:
       jar cvfm classes.jar mymanifest -C foo /
jar常用命令

压缩

jar -cvf xxx.jar


解压

jar -xvf xxx.jar


更新

jar -uvf xxx.jar BOOT-INF/classes/application-dev.yml


列出 jar 包内容

jar -tvf xxx.jar


运行 jar

java -jar xxx.jar
java -jar xxx.jar &
nohup java -jar &

  • &表示在当窗口关闭时,程序才会中止运行。&代表让该命令在后台
  • 命令 “nohup java -jar XXX.jar &” 表示不挂断运行命令,当账户退出或终端关闭时,程序仍然运行。注意,该作业的所有输出被重定向到nohup.out的文件中。

nohup java -jar XXX.jar >temp.log &

  • 表示不挂断运行命令,当账户退出或终端关闭时,程序仍然运行,并且该作业的所有输出被重定向到temp.log的文件中。“ > temp.log ” 该命令就是指定日志输出的文件。
    ">>"表示将输出以追加的方式重定向到Log.log中。

nohup java -jar XXX.jar >>temp.txt &
nohup java -jar XXX.jar > /dev/null 2>&1 &

  • 标准输入文件(stdin):stdin 的文件描述符为0,Unix 程序默认从 stdin 读取数据。
  • 标准输出文件(stdout):stdout 的文件描述符为1,Unix 程序默认向 stdout 输出数据。
  • 标准错误文件(stderr):stderr 的文件描述符为2,Unix 程序会向 stderr 流中写入错误信息。
  • 屏蔽输出,起到禁止输出作用:/dev/null 是一个特殊的文件,写入到它的内容都会被丢弃;如果尝试从该文件读取内容,那么什么也读不到。但是 /dev/null 文件非常有用,将命令的输出重定向到它,会起到"禁止输出"的效果。 “> Log.log 2>&1” :表示将 stdout 和
    stderr 合并后重定向到 Log.log
  • 可通过jobs命令查看后台运行任务

好事定律:每件事最后都会是好事,如果不是好事,说明还没到最后。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值