I read so many articles / explanations about this and spent too many hours, but everything is either too broad or specific.
This question really only applies to the Applet I made. It contains one class and requires 2 other Jar libraries. I included them in projects (several projects because I tried this in Netbeans and Eclipse ... it's easy to recreate a project of one class). The fact is that my HTML / web project should not deal with or reference more than one Jar. This is not a complicated applet / project at all.
I originally did this on Netbeans. It has the main package, and after adding 2 Jars they are placed in the "Libraries" area ("resources" folder). After creating it, Netbeans creates a Jar for my one package / class, and then puts the other two libraries in the "lib" directory next to it. I would like them to be in one distributed bank. Of the many things I looked at, I tried putting the following in build.xml:
<target name="YourBigJar" depends="-post-jar"> <jar destfile="dist/BigJar.jar"> <zipfileset src="dist/cxapplet.jar"/> <zipfileset src="resources/dpotapi.jar"/> <zipfileset src="resources/dpotjni.jar"/> </jar> </target>
But it does not produce anything. I got this from NetBeans - deploying in just one bank . I donβt know / understand how to use build.xml, so I wonβt be surprised if something goes wrong (obviously), but I do not have error / warning messages.
When I did this in Eclipse, it effectively merges them, but when I use Jar in my actual web project, it says that it cannot find classes from the other 2 jars. I would not understand how to fix it, but is it a class problem? In Eclipse, I create a new directory called "lib" and put the Jars in it. Then I right-click the project, go to the "Java Build Path" and add the Jars, also checking them on the "Order and Export" tab. From everything that I read, I right-clicked the project, select "Export", select "Jar", uncheck the ".classpath" and ".project" files, just check "Export generated class and resource files", and then allow it to generate a manifest file. As I said, this generates one Jar, but its contents are my package, and then the "lib" directory, in which there are two other Jars. There is a manifest, but it is quite empty and does not refer to any files (not sure if this is important). When I put this in my web application, it says that the applet cannot find other classes.
It just seems simple - one package / class, two external Jars ... merge into one Jar when it is created for distribution as an applet. Any ideas?
UPDATE:
Ever since we started using Maven, someone has learned to use the Maven plugin. So, we finished creating a new project to host the applet (since it was used for several projects) and used it in our pom.xml , at the end:
<build> <resources> <resource> <directory>${basedir}/applet</directory> <excludes> <exclude>codesignstore</exclude> </excludes> </resource> <resource> <directory>${basedir}/src/main/resources</directory> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-5</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <finalName>cxapplet</finalName> <archive> <index>true</index> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> </archive> <appendAssemblyId>false</appendAssemblyId> </configuration> <executions> <execution> <id>make-my-applet-jar</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jarsigner-plugin</artifactId> <version>1.2</version> <executions> <execution> <id>sign</id> <goals> <goal>sign</goal> </goals> </execution> </executions> <configuration> <keystore>${basedir}/applet/codesignstore</keystore> <alias>codesigncert</alias> <storepass>HIDDEN</storepass> <keypass>HIDDEN</keypass> </configuration> </plugin> </plugins> </build>
And it was nice because it allowed us to use our code signing certificate to automatically sign it.