Java magic Hall: jar for packaging knowledge points

Source: Internet
Author: User

Java magic Hall: jar for packaging knowledge points
I. preface it is very convenient and convenient to export jar packages through eclipse, but can I use it as a code farmer to meet the convenience of GUI? So come to CLI together! 2. The JAR package is based on the ZIP file format. It is used to Package Multiple. java files and various resource files, or multiple. Classes and various resources into one file. It is used to publish, deploy, encapsulate libraries, components, and plug-ins, and is used by the compiler and JVM. 3. package through the jar command. 1. format: jar [option] * required file name (and only one of them can be selected)-c, create a jar package-t, display the list of contents in the jar package-x, decompress the jar package-u and add the file to the jar package. The optional option-v is used to generate a detailed report and output it to the standard output device-m, which is used to specify the manifest. mf file. (META-INF/MANIFEST is automatically generated by default. MF file)-O, the content is not compressed-M when the jar package is created, and manifest is not automatically generated. mf file-I, create META-INF/INDEX when creating the jar package. LIST index file-C, indicates to switch to the specified directory to execute the jar command-f, specify the file path of the jar package 2. directory structure of common examples: Copy code/| -- src | -- test. class | -- META-INF | -- MAINFEST. MF | -- MAINFEST. MF | -- other | -- additional. class copy code command: Copy code/* 1. the src is packaged by default. jar contains src directory and jar automatically generated META-INF directory (contains MAINFEST. MF configuration file) jar-cvf src. jar src/* 2. view the package content (cannot be viewed if the jar is too large) */Jar-tvf src. jar/* 3. decompress the jar package */jar-xvf src. jar/* 4. extract part of the jar package */jar-xvf src. jar src \ test. class/* 5. append the content to the jar package * // append MAINFEST. files other than the MF list file will be appended with the entire directory structure jar-uvf src. jar other \ additional. class // append the list file to append the entire directory structure (src. jar will contain META-INF directory) jar-uMvf src. jar META-INF \ MAINFEST. MF/* 6. create a custom MAINFEST. MF jar package */jar-cMvf src. jar src META-INF // configure custom MAINFEST with the-m option. when the MF file is used, the MAINFEST is customized. the MF file must be in the working directory. Vf MAINFEST. MF src. jar src copy code 3. Export jar from Eclipse right-click the package and class to be exported and select "JAR file" under "Java ", then the next step is OK. 4. An executable JAR package when the jar package contains an executable program, you can use the java-jar src. jar command to execute the executable program. The packaging process is no different from the above operation, that is, a step more-configure the META-INF/MAINFEST. MF file. The contents of META-INF directory and META-INF/MAINFEST. MF list file will be discussed in Java magic Hall: META-INF of packaging knowledge point/MAINFEST. MF.

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.