0

I have a plain old Java project that uses a third party library: that is, a third party JAR added to its build path. I have exported the library as a JAR, added it to another plain old Java project's build path and when I run the project, I'm getting a Could not find class error for a class which is in the third party JAR library, not mine. That is, the exception is getting thrown in MY JAR file because it cannot find a class in the THIRD PARTY JAR which is contained IN my JAR.

I noticed that I can fix the issue if I also add the third party JAR to the original project's build path, but I really do not want to do that. I just want my JAR to be self contained and keep the third party JAR in it. Is there a way to do this?

AxiomaticNexus
  • 6,190
  • 3
  • 41
  • 61
  • If the third party library is contained in the jar file you created, you shouldn't be facing this problem. Can you double check that this indeed is the case i.e. the third party library is being exported? – Vikram Aug 31 '13 at 21:14
  • I have checked and rechecked. The third party JAR is in my JAR. The library works fine on simple Java apps, but not on Android. – AxiomaticNexus Aug 31 '13 at 21:18
  • If you are using Eclipse with the R22 tools, make sure the Order & Export portion of your build path is OK: http://stackoverflow.com/questions/16596969/libraries-do-not-get-added-to-apk-anymore-after-upgrade-to-adt-22/16596990#16596990 – CommonsWare Aug 31 '13 at 21:38
  • Those settings are fine. The problem is not with my JAR, the problem is with the nested JAR. – AxiomaticNexus Aug 31 '13 at 21:43
  • Scratch that. Actually it doesn't work on plain Java projects either. My Java project was using a reference to another project in the workspace, not the JAR; my mistake. So now the question changes to, how to do this with Java overall, not just Android. – AxiomaticNexus Aug 31 '13 at 22:14
  • If possible, post a link to the jar file. – Vikram Sep 01 '13 at 16:20

0 Answers0