Creating JAR WAR and EAR files
suggest changeJAR, WAR, and EAR files are ZIP files with a manifest and, for WAR and EAR files, a required internal directory layout.
The recommended way to create these files is to use a Java-specific build tool which “understands” the requirements for the respective file types. If you don’t use a build tool, then IDE “export” is the next option to try.
(Editorial note: the descriptions of how to create these files are best placed in the documentation for the respective tools. Put them there. Please show some self-restraint and DON’T shoe-horn them into this example!)
Creating JAR and WAR files using Maven
Creating a JAR or WAR with Maven is a matter of putting the correct <packaging> element into the POM file, for example:
<packaging>jar</packaging>
or
<packaging>war</packaging>
Maven can also build an executable JAR by setting the entry-point class and external dependencies as plugin properties of the Maven JAR plugin. A separate plugin can build an “uberJAR” that combines an application and its dependencies into one JAR file.
See the Maven documentation for more information.
Creating JAR, WAR and EAR files using Ant
The Ant build tool has separate tasks for building JAR, WAR, and EAR files. See the Ant documentation for more information.
Creating JAR, WAR and EAR files using an IDE
The three most popular Java IDEs all have built-in support for creating deployment files. The functionality is often described as “exporting”.
Creating JAR, WAR and EAR files using the jar command.
It is also possible to create these files “by hand” using the jar command. It is simply a matter of assembling a file tree with the correct component files in the correct place, creating a manifest file, and running jar to create the JAR file.
See the jar command topic for more information.