简体   繁体   中英

Generating jar but not including external libs

I'm trying to create a jar that will be used by multiple projects. This jar has code and includes some external libraries. Example: org.apache.http.HttpEntity

The problem is that after generating the jar of the "utility" project, and after including this new jar in other projects, I get an NoClassDefFoundError when I run the new project:

Oops: NoClassDefFoundError
An unexpected error occured caused by exception NoClassDefFoundError: org/apache/http/HttpEntity

The error is being lauched right after a class from this "utility" jar is accessed.

This new jar is being copied to the lib folder inside a new project and then added as Referenced Library using the eclipse.

Any suggestions?

Thank you guys!

Problem solved. Seems that, even if the libs are included in the generated jar, the project that would be receiving that generated jar also needs to include all of those libraries (used inside the exported jar). This doesn't seem right but it worked. Probably some misconfiguration in the exporting option.

When you add your jar to another project, you also need to add any jars that your jar depends on to the project's build path. So that means, to your final project you need to add both: your jar class library and the jar containing org.apache.http.HttpEntity .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM