Building JAR that includes all its dependencies

前端 未结 5 2116
盖世英雄少女心
盖世英雄少女心 2020-12-06 12:14

This is probably a really fundamental question, but I\'m afraid I don\'t know much about Java and I couldn\'t find the answer anywhere.

I\'m attempting to build an A

5条回答
  •  抹茶落季
    2020-12-06 12:40

    When you build a jar you get a JAR containing just your code, and not any dependencies your Jar requires. You could use something like jarjar to combine all the dependencies into one easy to manage Jar file or copy all the depend JARs into a folder for ease of use. It looks like Eclipse has options to also do this kind of thing (see posts above).

    The other option would be to use a dependency management system such as Maven or Ivy. This has a higher learning curve, but for a library it is worthwhile as it will allow users of your library to easy grab all the dependencies. For an end user application then a single distributable is likely a better option (for which you could use Maven or Ivy to internally manage the dependencies and then something like jarjar or Java Web Start to distribute to your end users).

提交回复
热议问题