If you need to reference additional jar packages as resource files in your Java project, you need to customize the configuration file manifest. MF as follows:
Manifest-version: 1.0
Class-path: lib/Crimson. Jar lib/jbcl. Jar lib/JUnit. Jar lib/log4j-1.2.13.jar lib/mysql-connector-java-3.1.13-bin.jar
Main-class: SRC. yourmainclassname
The class-paht specifies the location of the external jar package. Note that we assume that our project is packaged as a project. jar, according to the above definition, it should be in the project. create a lib folder under the same-layer directory of jar, and put the relevant jar package in it. Otherwise, the exception in thread "Main" Java. Lang. noclassdeffounderror error may occur.
Finally, let's introduce how to use eclipse to create a jar package:
1. Open the project in eclipse, right-click the project, and select "Export ";
2. Select Java/JAR file and next;
3. In select the resources to export, you can select the project folder you want to include. Some unnecessary folders do not need to be put in, so as not to increase the space;
There are several options:
* Export generated class files and Resources indicates that only generated. class files and other resource files are exported.
* Export all output folders for checked projects: export all folders of the selected project
* Export Java source file and Resouces indicates that the exported jar package will contain yourSource code*. Java, if you do not want to leak the sourceCode, So do not select this option.
* Export refactorings for checked projects include some reconstructed information files.
In select the export destination, select the path of the exported jar, next
4. On the next page, you can choose whether to export the *. class files containing warning warnings or error errors. Ignore him, next
5. Configure the project on the next page.
* Generate the manifest file is used by the system to automatically generate the manifest. MF file. If your project does not reference other class-path files, you can select this item.
* Use existing mainfest from workspace. This is a custom. MF file. The format is as shown above.
* Seal content. Packet
* Main class. Here you can select yourProgramThe jar package in the future is the execution result of your entry class.
Finish.