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.