Creating JAR WAR and EAR files

suggest change

The JAR, WAR and EAR files types are fundamentally ZIP files with a “manifest” file and (for WAR and EAR files) a particular internal directory / file structure.

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 using Maven is simply a matter of putting the correct <packaging> element into the POM file; e,g,

<packaging>jar</packaging>

or

<packaging>war</packaging>

For more details. Maven can be configured to create “executable” JAR files by adding the requisite information about the entry-point class and external dependencies as plugin properties for the maven jar plugin. There is even a plugin for creating “uberJAR” files that combine an application and its dependencies into a single JAR file.

Please refer to the Maven documentation ( http://stackoverflow.com/documentation/maven/topics )for more information.

Creating JAR, WAR and EAR files using Ant

The Ant build tool has separate “tasks” for building JAR, WAR and EAR. Please refer to the Ant documentation ( http://stackoverflow.com/documentation/ant/topics ) 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.

Please refer to the jar command Topic ( http://stackoverflow.com/documentation/java/5247/creating-and-modifying-jar-files ) for more information

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Java deployment:
* Creating JAR WAR and EAR files

Table Of Contents
8 Arrays
10 Maps
11 Strings
25 JAXB
29 Enums
32 Audio
41 Scanner
63 Logging
75 Lists
78 Sets
89 JAX-WS
96 XJC
98 Process
106 Modules
114 Applets
122 JNDI
131 Java deployment
139 JavaBean
141 Literals
144 Packages
150 JMX
153 JShell
159 Sockets
167 Enum Map
175 Hashtable
177 SortedMap