Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the specific method for Linux to extract the jar package?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail what is the specific method of decompressing jar package with Linux. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

How does Linux extract the jar package? JAR file is Java Archive File, as the name implies, its application is closely related to Java, is a document format of Java. The JAR file is very similar to the ZIP file-to be exact, it is the ZIP file, so it is called the package.

Specific method of decompressing jar package by Linux

1. Linux decompression jar package command jar command detailed explanation

Jar command options:

Jar command format: jar {c t x u f} v m e 0 MI file name.

One of the four options {ctxu} must be chosen. [v f m e 0 mi] is optional, and the file name is required.

-c create a jar package

-t displays a list of contents in jar

-x extract the jar package

-u add files to the jar package

-f specifies the file name of the jar package

-v generate detailed report and output to standard equipment

-m specifies the manifest.mf file. (you can set the jar package and its contents in the manifest.mf file.)

-0 does not compress the contents of the jar packet when it is generated

-M does not produce manifest files (Manifest.mf) for all files. This parameter is related to the setting of the-m parameter ignored.

-I create an index file for the specified jar file

-C means to go to the appropriate directory and execute the jar command, which is equivalent to cd to that directory, and then execute the jar command without-C.

II. Linux decompression jar package command jar usage example

(1) create jar package

$jar cf hello.jar hello uses the test directory to generate hello.jar packages. If hello.jar exists, it overrides

(2) create and display the packaging process

$jar cvf hello.jar hello creates a hello.jar package using the hello directory and shows the creation process

Example: e: > jar cvf hello.jar hello

Marked list (manifest)

Added: hello/ (read in = 0) (write = 0) (0% stored)

Added: hello/TestServlet2.class (read in = 1497) (write = 818) (compressed 45%)

Added: hello/HelloServlet.class (read in = 1344) (write = 736) (compressed 45%)

Added: hello/TestServlet1.class (read in = 2037) (write = 1118) (compressed 45%)

(3) display jar package

$jar tvf hello.jar to view the contents of the hello.jar package

The specified jar package must be real, or FileNoutFoundException will occur.

(4) decompress the jar package

$jar xvf hello.jar decompress the hello.jar to the current directory

(5) add files to jar

$jar uf hello.jar HelloWorld.java adds HelloWorld.java to the hello.jar package

(6) create an uncompressed content jar package

$jar cvf0 hello.jar * .class generates an uncompressed jar package using all .class files in the current directory

(7) create a jar package with manifest.mf file

$jar cvfm hello.jar manifest.mf hello

The created jar package has an extra META-INF directory, and META-INF has recorded an extra manifest.mf file. As for the role of manifest.mf, it will be mentioned later.

(8) ignore manifest.mf files

The META-INF directory and manifest.mf files are not included in the jar package generated by $jar cvfM hello.jar hello

(9) add-C application:

$jar cvfm hello.jar mymanifest.mf-C hello/

Means to change to the hello directory and then execute the jar command

(10)-I generate an index list for the jar file

When the content in a jar package is good, you can generate an index file for it, which looks easy.

$jar I hello.jar

After executing this command, it generates an index file named INDEX.LIST in the META-INF folder of the hello.jar package

It generates a list, topped by the jar package name.

(11) Export the decompression list

Jar tvf hello.jar > hello.txt

If you want to see the detailed process of decompressing a jar, and the jar package is very large, the screen message will flash by.

At this point, you can output the list to a file and enjoy it!

(12) jar-cvf hello.jar hello/*

For example, the original directory structure is as follows:

Hello

| |-com |

| |-org |

You want to package only the com directory and the org directory, but the jar command will be packaged along with the hello directory.

We should pay attention to this point. The compressed file generated by the jar command contains the directory that comes out after it. We should go to the hello directory and execute the jar command.

Note: the file name manifest.mf can be specified by the user, but the jar command only knows Manifest.mf, and it will convert the file name specified by the user accordingly, which does not need to worry the user.

Third, linux decompression jar package command JAR command use skills

(1) jar creates compressed ZIP files

Jar cvfM TestZIP.jar test plus M parameter in order not to generate META-INF related content

Then change TestZIP.jar to TestZIP.zip, isn't it very simple? .

(2) use WinRAR to extract the .jar file

As we have already said above, the JAR file is a special compressed file, so of course it can be unzipped with some of our commonly used decompression tools.

As for how to solve it, there is no need for me to say.

(3) generate .jar files with WinRAR

We have already said that the main difference between the JAR package and the ZIP package is that there is an extra META-INF directory in the JAR package.

There is a manifest.mf file in the META-INF directory. We just need to set up the relevant directory and compress it.

The structure of the directory is as follows:

TestJar

META-INF

Manifest.mf

| | related class files |

Note: should also fill in the content in manifest.mf, can not write? Just copy what you already have.

About Linux decompress jar package what is the specific method to share here, I hope the above content can have some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report