Include java libraries into own library

后端 未结 4 758
面向向阳花
面向向阳花 2021-01-26 09:59

I created a little framework for myself which I want to use in multiple projects. I also want the distributed jar-file to include all external libraries so that my projects just

相关标签:
4条回答
  • 2021-01-26 10:29

    The standard classloader can't find class files inside a jar that is itself inside a jar. You must add every jar to the classpath, and not nest jars.

    BTW, it would probably be a bad idea to allow nesting jars: you would end up with 6 or seven versions of commons-lang or log4j into every project, because many libraries depend on them.

    0 讨论(0)
  • 2021-01-26 10:44

    Depends on IDE...If you are using Eclipse then it is very easy...go to Properties->Build Path and then add library...

    0 讨论(0)
  • 2021-01-26 10:47

    You can use One-jar or Fat Jar. If you use maven you can use maven-assembly plugin.

    0 讨论(0)
  • 2021-01-26 10:48

    You can publish a Maven artifact, which users of your framework can then use without having to include the dependencies yourself--your pom is enough.

    If you want to create an "all-in-one" artifact, consider something like OneJar or jarjar or Maven's Shade plugin to create a jar that has no external dependencies.

    0 讨论(0)
提交回复
热议问题