What is a JAR package
JAR (Java Archive) is a Java Archive, which is a platform-independent file format that allows many files to be combined into a compressed file.
How to pack/unpack
Use the JDK /bin/jar.exe tool to configure environment variables and directly run the jar command.
Jar command format
Jar {c t x u f}[v m e 0 m I] jar {c t x u f}[v m e 0 m I]
{ctXU}, one of these four parameters must be selected.
[v f m e 0 m I], these parameters are optional, and the file name is required.
parameter | instructions |
---|---|
-c | Create a JAR package |
-t | Displays a list of contents in the JAR |
-x | Extract the jar package |
-u | Add files to the JAR package |
-f | Specifies the file name of the JAR package |
-v | Output detailed report |
-m | Specify the manifest.mf file |
0 | Jar packages are generated without compression |
-M | The MANIFEST file manifest.mf is not generated |
-i | Creates an index file for the specified JAR file |
-C | You can run commands in the corresponding directory |
Manifest.mf definition:
demo
Add files to jar packages
jar uf xxx.jar BOOT-INF/classes/application.yml
Extract the jar package
jar -xvf xxx.jar
Jar package, no generated list 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 or update some files to an online JAR package.
Tutorials: The most powerful Spring Boot & Cloud tutorials ever
Tools: Recommended an online creation flow chart, mind mapping software
Scan follow our wechat public number, reply “Java” can get stack length of a series of Java tutorials, are dry goods…