java - Creating a .jar file which includes other .jar files? -
i'm trying create .jar file (this first time) , i'm confused. understand how utilize command prompt create simple jar file, programme import javamail api , library created (called arraylibrary filled sorting methods). how create these in 1 jar file?
i've read jarsplice, right tool using problem?
this question gets asked frequently, should technically marked duplicate, looking @ previous questions, wasn't able find suitably comprehensive answer. so, here's effort @ providing one:
firstly, java specs don't allow embedding jar files within other jar files. there projects out there provide specialized classloaders allow this, none i'm aware of work in situations.
as background, .jar file .zip contains java class files , resources, in same tree-structure you'd find in file scheme if hadn't jar'd them. can create .jar file 'jar' utility or zip utility - rename .zip file .jar, , should work fine.
so, reply expand (un-jar, unzip) of jar files directory structure, , jar them up. new jar file contain of artifacts of original jar files.
the problem doing manually, besides beingness tedious, multiple jar files may contain resources of same name (for instance, manifest.mf file). you'd have manually combine manifests maintain things working properly.
so, number of tools have been created automate this. jarsplice seems 1 of these, though i've never heard of before, can't whether works or not.
my personal recommendation bit involved, has other benefits: create maven build project. add together maven-assembly plugin project, , utilize build 1 big jar (known uberjar).
the additional benefits have solid build scheme project, no longer dependent on ide build project, , other people (or you, later) can build project in standard way, without requiring utilize of particular ide.
there may similar gradle, or there may way utilize maven plugin gradle, haven't researched that.
while wouldn't recommend it, can ant , it's uberjar plugin.
java jar
No comments:
Post a Comment