Executable JAR & Ant?

Unless you are willing to write a custom classloader, the manifest classpath does not support nested JARs. Instead, a typical approach is to place any third party binaries and your JARs in the same (or well known) directory, and refer to one another using manifest classpaths. Remember that that entries in the manifest classpath are relative to the main jar So for some non-trivial project, your distribution layout may look like: apphome +-- bin +-- command1.Sh / .

Bat (to supply -Xmx etc) +-- command2. Sh / . Bat ... +-- lib +-- module1.

Jar +-- module2. Jar ... +-- command1. Jar (manifest cp contains modules, 3rd party, main-class) +-- command2.

Jar ... +-- deps +-- 3rdparty1. Jar +-- 3rdparty2.jar.

Unless you are willing to write a custom classloader, the manifest classpath does not support nested JARs. Instead, a typical approach is to place any third party binaries and your JARs in the same (or well known) directory, and refer to one another using manifest classpaths. Remember that that entries in the manifest classpath are relative to the main jar.So for some non-trivial project, your distribution layout may look like: apphome +-- bin +-- command1.

Sh / . Bat (to supply -Xmx etc) +-- command2.Sh / . Bat ... +-- lib +-- module1.

Jar +-- module2. Jar ... +-- command1. Jar (manifest cp contains modules, 3rd party, main-class) +-- command2.

Jar ... +-- deps +-- 3rdparty1. Jar +-- 3rdparty2. Jar ...

Thanks Dilum, but now I'm even more confused! If I can't put dependency JARs inside my executable JAR, then when I release my executable JAR to a user, how do they gain access to the dependencies (since they weren't included in the JAR). For instance, if my executable JAR is a command line tool which uses Apache Commons CLI, and I don't include CLI in my JAR, how does someone trying to use this application on a remote machine gain access to the CLI JAR?

– zharvey Sep 6 at 17:43 @Mara You have to release your executable JAR and additionally include the JARS for your dependencies. – Marcelo Sep 6 at 18:03 @Mara, you distribute ZIP file that contains everything. If you wanted to be clever, I suppose you could distribute an executable JAR that is an installer, but that's beyond the scope of this question.

Note also that some users (me included) prefer a simple zip file over an installer... – Dilum Ranatunga Sep 6 at 18:19.

I'm writing an Ant build. Xml file for an executable JAR for the first time, and am stumped as to what I need to include in the JAR. Here's my question: since this is an executable JAR, should I be JARring up all the dependency JARs as well, or should I keep them separate?

I suspect I need to include them in the JAR, and if this is true, what would best practices dictate for organizing my JAR? Where com/ is my top-level package, lib/ is a directory housing all of these dependencies, and config/ holds the required XML files. (1) Any thoughts?

Also, as a side question, since the JAR file will have a different directory structure than my Eclipse project, I need someway of setting up the classpath for my JAR (so it knows to look in, say, lib/ for its dependencies), as well as specifying where to look for my Spring XML file. (2) How do I configure this in the JAR - the manifest file? There must be some way to configure the manifest (or whatever is the answer to this question) file through Ant so I don't need to manually edit the JAR every time I build.

Thanks for any input!

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions