0

I just want to know how to include a jar file that has all dependent jars with it, as a dependency itself of an another project. I have tried export as runnable jar option and though it does work when I run the project as standalone, however I get noclassdeffound errors when I include the jar itself as a dependency for another project. To summarize suppose I have project A which depends upon some external jars a.dep1 and a.dep2 I include them in the jar by exporting the project A as a runnable jar file. Now I wish to use project A itself as a dependency in project B and for that purpose I include the jar of project A in my project B. But when trying to run I get the noclassdeffound errors. I don't want to use maven plugins. Is this possible?

GhostCat
  • 137,827
  • 25
  • 176
  • 248
JayD
  • 748
  • 1
  • 13
  • 38
  • if you're using maven, have a look at the shade plugin. it allows you to create uber jars containing all dependencies – Jan Gassen Jan 07 '19 at 15:03
  • 2
    The real point here is: why dont you want to use existing solutions to this problem? Whats wrong with using maven, and maven technology that solves your problem? – GhostCat Jan 07 '19 at 15:07

2 Answers2

0

for such cases you should be using maven then you need to create a fat jar. a fat jar will include all the dependencies it needs inside . such a jar can be created using the assembly plugin you can see an example here:

assembly plugin

in general if you are using maven you do not have to do this as maven will bring all the dependencies your jar needs based on the pom file of your first jar.

Raven
  • 713
  • 2
  • 10
  • 21
0

A jar is just a collection of files; you have free rein on what you want to include in it via the command line. https://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html should teach you what you need to know