Use eclipse packaging to generate jar files to resolve classpath issues

Source: Internet
Author: User
Tags log4j

When you publish a javase project, you often need to make the project a jar package, and when you have dependencies on Third-party jar packs in your project, you need to resolve the classpath issues about the Third-party jar packs when you package your own projects. Here's how to achieve these goals under eclipse:


In the project needs to export the jar file class, such as the above Testjar.java on the right click, select Export, how to change the file has main function, select runnable jar file,


Select Copy, need to rely on the package to the subdirectory, select Finish, export complete, should be able to see Myjar.jar and a directory myjar_lib, in the Myjar_lib directory, storing all the project dependencies.

Use the decompression software to view the MAINFEST.MF in the Myjar.jar file


You can see the Class-path entry, followed by the dependency package, included. (current directory), because I used the log4j, so copy log4j.properties file to, and Myjar.jar the same directory


As shown in the figure above, you can then execute your own project under CMD, Java-jar Myjar.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: 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.