Compression and decompression of Jar packet in Java
This article focuses on "compression and decompression of Jar packages in Java". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the compression and decompression of Jar packages in Java.
What is a jar package?
JAR (Java Archive) is an archive of Java, a platform-independent file format that allows many files to be combined into a single compressed file.
How to hit / unpack
Using the jdk/bin/jar.exe tool, you can use the jar command directly after configuring the environment variables.
Jar command format
Jar {c t x u f} [v m e 0 MI] [- C directory] file name.
{ctxu}, one of these four parameters must be selected.
[v f m e 0 mi], these are optional parameters, and the file name is also required.
Parameter description-c create a jar package-t display contents list in jar-x extract jar package-u add file to jar package-f specify file name of jar package-v output detailed report-m specify MANIFEST.MF file-0 do not compress content when generating jar package-M does not generate manifest file MANIFEST.MF-i creates an index file for the specified jar file-C can execute commands in the appropriate directory
About the MANIFEST.MF definition:
Https://baike.baidu.com/item/MANIFEST.MF
Demo
Add files to the jar package
Jar uf xxx.jar BOOT-INF/classes/application.yml
Extract the jar package
Jar-xvf xxx.jar
Jar package, no manifest file, no compression
Jar-cvfM0 xxx.jar BOOT-INF/ META-INF/ org/
Or
Jar-cvfM0 xxx.jar *
These commands may be useful if you want to add and update some files to the online jar package to the jar package.
At this point, I believe you have a deeper understanding of "compression and decompression of Jar packages in Java". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!