How to compress the java. Class file into a jar package?

Source: Internet
Author: User

Method 1:
In eclipse, you can export jar files (similar to EXE files, but supported by Java Virtual Machine) and execute file → export → jar (runable.
Eclipse --> right-click a Java project --> export --> JAVA-JAR file/runnable JAR File
// It can also be a package under the project

 

Method 2:
Jar command:
Example 1: Archive two class files to an archive file named 'classes. jar:
Jar CVF classes. Jar Foo. Class bar. Class

Example 2: use an existing manifest file 'mymanifest'
Archive the file to an archive file named 'classes. jar:
Jar cvfm classes. Jar mymanifest-C Foo /.

 

Jar usage:Jar {ctxu} [vfm0mi] [Jar-file] [manifest-file] [-C Directory] File Name...

Option:
-C. Create a new archive
-T list the archived content
-X expand the named (or all) files in the archive
-U: update an existing archive
-V generates detailed output to the standard output
-F specifies the archive file name
-M contains the marker information from the specified file.
-0 storage only; zip compression format not used
-M does not generate a manifest file for all items
-I generates index information for the specified JAR File
-C changes to the specified directory and contains the following files:
If a file name is a directory, it is recursively processed.
Both the configuration (manifest) file name and the archive file name must be specified, in the same order specified by the 'M' and 'F' signs.

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.