简体   繁体   中英

How can I export the libs of a project in the jar?

I'm making an Android library to implement generalized OAuth Authentication(both 1.0a and 2.0). I'm using the signpost libraries for signing the Http Requests. Now when I try to export my project as a .jar file(using Eclipse, right click on Project->Export->Java->Jar file), the jar gets created successfully, but it hasn't exported the signpost libraries.

When I open the .jar file, I find that the libraries are present, but they aren't visible to the project I'm importing it in. How can I expose these libraries from the jar?

EDIT: Once I import the library into my test application and call the function, OAuthFactory#authorize() (A custom class that handles OAuth authentication), I get the following compile error: The type oauth.signpost.exception.OAuthCommunicationException cannot be resolved. It is indirectly referenced from required .class files The type oauth.signpost.exception.OAuthCommunicationException cannot be resolved. It is indirectly referenced from required .class files .

this question has also been discussed here.

How to combine library with my jar?

Of course, you can extract the library-jars and add the extracted class-files into your own jar, but you would lose the clear view to the external lib's versions this way.

The solution that works best for me is to ship your JAR-file with an additional folder that contains all external JAR-Files and then refer to them in your /META-INF/MANIFEST.MF:

Class-Path: lib/kxml2-2.3.0.jar lib/log4j-1.2.16.jar

You can leave the JAR-Files external this way and won't have to blow up your own JAR-file.

Greetings

Christopher

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