1

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.

Vinay S Shenoy
  • 4,028
  • 3
  • 31
  • 36

1 Answers1

1

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

Community
  • 1
  • 1
Christopher Stock
  • 1,399
  • 15
  • 18
  • I did do that(extracting the class files from the library and repackaging it, but it was a rather messy solution, IMO. I'll try the solutions you've linked and get back to you. – Vinay S Shenoy Dec 19 '12 at 11:24
  • Yes - I agree that it's a bad solution to include extracted foreign class-files to your jar. AFAIK, packing JAR-files into another JAR is not intended by Java. I think that the solution I described is the best and generic one. – Christopher Stock Dec 19 '12 at 12:39