Restore the jar package after decompression

Restore the jar package after decompression

Remember to restore the jar package once

A JAR file is a Java Archive (Java Archive) , which is a documentation format for Java. A JAR file is very similar to a ZIP file
. To be precise, it is a ZIP file , so it is called a package. The only difference between a JAR file and a ZIP file is that there is an extra META-INF/MANIFEST.MF file in the content of the JAR file . This file is automatically created when the JAR file is generated (you can also create it yourself)

jar package restore

After decompressing the jar package of the Soring boot project, modify the file and recompress the jar package without relying on development tools. The packaging command is as follows:

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

jar command parameters

[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 /

common jar commands

compression

jar -cvf xxx.jar


decompress

jar -xvf xxx.jar


renew

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


List jar package contents

jar -tvf xxx.jar


run jar

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

  • & indicates that the program will stop running when the window is closed. & means to let the command run in the background
  • The command "nohup java -jar XXX.jar &" indicates that the running command will not be hung up, and the program will still run when the account is logged out or the terminal is closed. Note that all output from this job is redirected to the nohup.out file.

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

  • It means to run the command without hanging up. When the account is logged out or the terminal is closed, the program still runs, and all the output of the job is redirected to the temp.log file. " > temp.log " This command is to specify the log output file.
    ">>" indicates that the output will be redirected to Log.log by appending.

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

  • Standard input file (stdin): The file descriptor of stdin is 0, and Unix programs read data from stdin by default.
  • Standard output file (stdout): The file descriptor of stdout is 1, and Unix programs output data to stdout by default.
  • Standard error file (stderr): The file descriptor of stderr is 2, and Unix programs will write error messages to the stderr stream.
  • Mask output to prevent output: /dev/null is a special file, and the content written to it will be discarded; if you try to read from this file, you will not be able to read anything. But the /dev/null file is very useful. Redirecting the output of a command to it will have the effect of "disabling output". "> Log.log 2>&1": Indicates that stdout and
    stderr are merged and then redirected to Log.log
  • You can view background running tasks through the jobs command

The law of good things: Everything will be a good thing in the end, if it is not a good thing, it means that it is not the end yet.

Guess you like

Origin blog.csdn.net/Cike___/article/details/122037698