Download Java and java

Source: Internet
Author: User

Download Java and java
Decompress and package Jar
Address: http://blog.csdn.net/caroline_wendy
Introduction1. Compressed package: Jar cvf filename. jar a. class B. class: compress the specified file; jar cvf weibosdkcore. jar *: compress all;
2. decompress the package: Jar xvf test. jar
DetailsJar commandYesGenerate, view, update, and unlockThe role of the jar package, includingMETA-INF/MANIFEST. MFFile. It isJar packageAutomatically created when the jar package is generated.Main File LocationAndCurrent folder. Detailed description of jar command parameters:

C:\>jar cf lm.jar
The 'C' flag requires a list or input file! Usage:
jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
Options include:-c create a new archive file-t list the archive directory-x decompress the archive specified (or all) file-u update existing archive file-v generate detailed output in standard output-f specify archive file name-m contain configuration information in the specified inventory file-e is bundled to the executable jar File the independent application specified application entry point-0 is stored only; do not use any ZIP compression-M do not create a project list file-I generate index information for the specified jar file-C change to the specified directory and contain the files if there is any directory file, then it is recursively processed. The order of configuration file name, archive file name, and entry name is the same as that of m, f, and e.
Example 1 Archive two class files to an archive file named classes. jar:
jar cvf classes.jar Foo.class Bar.class

Example 2 use the existing inventory file "mymanifest" and archive all the files in the foo/directory to "classes. jar:
jar cvfm classes.jar mymanifest -C foo/ .

Example 3 created under drive C Executable Jar FileType lm. jar package.
C:\>jar cf lm.jar Lm.class Lm.java

Example 4 Add the v parameter to display the detailed packaging process:
C:\jar>jar cvf lm.jar Lm.class

Manifest: Lm. class (read = 410) (write = 283) (compressed by 30%). The c parameter indicates creating a jar package, and the f parameter indicates the specified jar package file name. When using the jar command, you must specify the required parameters:-c to create a new archive file-t to list the archive directory-x to decompress the archive specified (or all) file-u updates existing archive files
Example 5 run the generated jar package:
 C:\>java -jar lm.jar
Failed to load Main-Class manifest attribute from lm. jar according to the English error message, it seems that reading the manifest attribute of lm. jar package Failed.
Example 6 create a jar package that does not contain the META-INF/MANIFEST. MF File
C:\jar>jar cvfM lm1.jar Lm.class
Added: Lm. class (read = 410) (write = 283) (compressed by 30%)
Example 7 show the files in the jar package
C:\jar>jar tf lm.jarMETA-INF/META-INF/MANIFEST.MFLm.class

Example 8 since the M parameter is used when creating the jar package, there is no META-INF directory and META-INF/MANIFEST. MF File
C:\jar>jar tf lm1.jarLm.class

Example 9 shows detailed information about the files and files in the jar package.
C:\jar>jar tvf lm.jar     0 Mon Sep 26 23:09:34 CST 2011 META-INF/    75 Mon Sep 26 23:09:34 CST 2011 META-INF/MANIFEST.MF   410 Mon Sep 26 22:09:00 CST 2011 Lm.class
The detailed information includes the read bytes, the time when the jar package is read, the directory or file name.
Example 10 unzip the jar package to the current directory
C:\jar>jar xf lm.jar
No information is displayed, but the decompression is successful.

Related Article

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.