Package the class into a jar file
First, look at the source code of Mainactivity.java and Func.java respectively.
Now to package the Func.java into a jar package, here's how:
A, right-click Func.java->export->java->jar file
b, select the class to be packaged in the select the resources to export, and note that if this class has calls to other dynamic/static libraries, it does not need to be selected together, only Java files are selected. The library file can be referenced with the jar in the new project directory. Then enter the Jae name and storage location, click Finish, such as:
At this point, the Func.jar is generated at the specified location
Ii. adding a jar package to the project
A. Put the jar package (and its library file) in the Libs folder (recommended) in the project directory.
b , in Eclipse, right-click the Java Build Path in Project--Properties, enter the Libraries tab
C, stand-alone "add JARS", find the Jar file, add. Ok
D. Directly using the classes in the jar
Java class packaged into JAR file &&jar package Introduction