Java class package into jar file & amp; introduction of jar package, java class package jar

Source: Internet
Author: User

Java class package into jar file & introduction of jar package, java class package jar

1. Package classes into jar files

First, let's take a look at the source code of MainActivity. java and func. java respectively.

To package func. java into a jar package, use the following method:

A. Right-click func. java-> Export-> Java-> JAR file

B. Select the class to be packaged in Select the resources to export. Note that if this class calls other dynamic/static libraries, Select only the java file. The library file can be referenced by placing it in the new project directory along with the jar file. Enter the JAE name and storage location, and click finish, for example:

In this case, func. jar is generated at the specified position.

2. Add a jar package to the Project

A. Put the jar package (and its library files) in the libs folder under the project file directory (this is recommended ).

B. In Eclipse, right-click the project and choose Properties> Java Build Path to go to the Libraries tab.

C. "Add JARS" on a single machine, find the jar file, and Add it. OK


D. Use the classes in jar directly.

How to Package Multiple class files in java into jar

In command mode, open the program | nearby | Command Prompt window, and enter the following command:
Jar cvfe result JAR file name. jar main class-C source bytecode folder.

How to package a java file into a jar file

Netbeans itself supports Automatic Export
Select export to find the jar.

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: 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.