Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #19532
| From | Sven Köhler <remove-sven.koehler@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: a question about creating the JAR file |
| Date | 2012-10-27 16:54 +0200 |
| Message-ID | <af2agsFbm4U1@mid.dfncis.de> (permalink) |
| References | <c34600e7-78d9-44a5-a79c-ee804ed992e2@googlegroups.com> |
Am 26.10.2012 22:58, schrieb zyng: > My confusion is do I need to bundle helper.jar into hello.jar? One > thought I have is that during compiling, all the code needed from > helper.jar has been extracted and combined into the generated *.clss > files in build/ directory. So, for creating hello.jar, I only need to > bundle all *.class files in build/ directory. But I am not sure that > is correct. > > Currently, I have to unjar(expand) helper.jar into build/ directory > before I jar everything in build/. The result hello.jar works fine. > If I skip unjarring helper.jar into build/ directory, no complain for > creating hello.jar. But when running it, an exception of no class > definition for a class inside helper.jar is thrown. There are at least two ways of doing this: 1) create hello.jar (for example with ant) and embed a manifest file, which includes helper.jar in the classpath. The good thing is: inside the manifest, you can use relative paths. Doring java -jar hello.jar, these paths will be resolved (AFAIK, relative to hello.jar) 2) unpack helper.jar, and include (almost) all files of helper.jar in hello.jar. Now it's not always possible to do that, especially if you have multiple JAR files. Some paths are reserved. For example, if you create a StAX XML Reader, the API search the classpaths for certain failes. Each files may contain the names of classes that implement the StAX API. Now when you merge multiple JAR files, you would have to merge these files as well. (This is actually a bad example, as you only want only one StAX implementation anyways, but it illustrates the problem) What about signed JARs? Now method (2) has gained popularity. Probably, because "big fat JAR plugins" for several IDEs exist (at least for Eclipse this is true). However, I think this method should be avoided for any big application. Regards, Sven
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
a question about creating the JAR file zyng <xsli2@yahoo.com> - 2012-10-26 13:58 -0700
Re: a question about creating the JAR file Lew <lewbloch@gmail.com> - 2012-10-26 14:14 -0700
Re: a question about creating the JAR file zyng <xsli2@yahoo.com> - 2012-10-31 12:41 -0700
Re: a question about creating the JAR file Lew <lewbloch@gmail.com> - 2012-10-31 15:19 -0700
Re: a question about creating the JAR file Sven Köhler <remove-sven.koehler@gmail.com> - 2012-10-27 16:54 +0200
Re: a question about creating the JAR file Jan Burse <janburse@fastmail.fm> - 2012-10-27 17:20 +0200
Re: a question about creating the JAR file Jan Burse <janburse@fastmail.fm> - 2012-10-27 17:24 +0200
Re: a question about creating the JAR file Sven Köhler <remove-sven.koehler@gmail.com> - 2012-10-27 19:06 +0200
Re: a question about creating the JAR file Lew <lewbloch@gmail.com> - 2012-10-28 09:44 -0700
Re: a question about creating the JAR file Roedy Green <see_website@mindprod.com.invalid> - 2012-11-01 18:26 -0700
csiph-web