Java-Preliminary Understanding-12th-object-oriented (Jar package)

Source: Internet
Author: User

One.

Java program we have encapsulated it in the package, Java program A lot of cases, packages a lot of cases, we plug it into a file. This is more convenient.

What are the benefits of this compression tool? You can synthesize multiple directories into a single file.

Java also has one such packaging tool, which is the jar. Unfortunately, the jar is not a graphical interface tool, it is a DOS tool.

How to operate the jar tool,

There is a source program called Jardemo.java, which is now compiled. To the present implementation of the compilation, are all with a package mechanism.

Finally run a bit, class file, no problem, can output the results normally. (It is important to note that when you run the class file, the package name prefix of the class file is added.) )

Now to get the folder to the compressed package, how to do it?

There is a JAR command tool located underneath the JDK folder.

Also consult the help information of the jar command,

Now it's time to get a better idea of what you can do with the advanced compiler.

Compression appears to be creating an archive file.

By the jar command to do compression processing,-C is a fixed notation, adding an F means that the file is compressed, the Haha.jar is the name of the compressed file.

What content should be put into Haha.jar? Put the pack pack in,

There is really a Haha.jar compressed file here, and I wonder if the pack is compressed inside?

Now in a different writing format,

The addition of V is marked with some detailed information.

Another way of writing,-TVF, is to see what's inside.

Then the decompression is done by the-XVF.

Meta-inf This is a compressed package of the manifest file, the name of the manifest file is fixed, and it can be added to a lot of compression package can use the key value attribute information. This information will come into contact later. I'm afraid this file Meta-inf the same name as the file you need to generate, so a separate file is listed.

In fact, the compression package is to pack this package more than a level directory (compressed directory).

To run this pack, you do not need to extract it at all. Just set the Class.path to pack this folder, or the parent directory where the package is located, to run. This is the benefit of the jar package.

Now directly run the compressed pack package, DOS results error.

There is no this package in the current directory, this package ran to the Haha.jar directory. Now you need to make some changes to run.

This means that jar packages can be used directly.

In real-world development, all the data is compressed into the jar package, and the other party receives it without extracting it. Put it in the classpath and you can use it directly.

Usually when we use third-party tools, what is a third party? Not officially written by individuals or organizations), this tool is good for my project development, so I go back to download the tool to use, it will be in the jar package, and the Doc folder with the API document, it will let you see the tool inside what objects, which methods can be used.

Java-Preliminary Understanding-12th-object-oriented (Jar package)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.