1. First, tools such as Eclipse are handy.
2. Use tools such as WinRAR, the Web-info directory, and all its peers and all the directories and files, packaged into a zip file, and then changed the extension to war!
3 jar Command:
Suppose you have a Web application: C:/myhome
myhome/web-inf/...
Myhome/files/...
myhome/image/...
myhome/src/...
myhome/index.jsp
Execute the following command in the Command line window:
C:/>CD MyHome
C:/myhome/>jar CVF Myhome.war * *.
Explanation: Jar CVF [a=] War package name].war [b= resource files and folders] [c=] will generate the target folder for the war package]
"*/" (b=) represents all files and folders under the current directory (C:/myhome).
"." (c=) indicates that a war package will be generated in the current directory.
Once the operation is complete, you can deploy the resulting war package. For example, use the Tomcat container: Find the newly generated Myhome.war under C:/myhome, copy it into tomcat_home/webapps/, and start Tomcat.
Attached: jar command usage: jar {ctxui}[vfm0me] [jar-file] [manifest-file] [entry-point] [-c dir] files ...
Options include:
-C Create a new archive file
-t lists the archive directory
-X Unzip the archived specified (or all) files
-U Update existing archive file
-V generates verbose output in standard output
-f Specifies the archive file name
-M contains inventory information from the specified manifest file
-E is a standalone application bundled into an executable jar file
Specify the application entry point
0 store only; do not use any ZIP compression
-M does not create an entry for the manifest file
-I generate index information for the specified jar file
-C changes to the specified directory and contains the files therein
If there is any catalog file, it is recursively processed.
The specified order of the manifest file name, archive file name, and portal name
Is the same as the specified order for the "M", "F", and "E" flags.
Example 1: Archive two class files into an archive named Classes.jar:
Jar CVF Classes.jar Foo.class bar.class
Example 2: Use the existing manifest file "Mymanifest" and
Archive all files in the foo/directory to "Classes.jar":
Jar CVFM Classes.jar mymanifest-c foo/.
War File Packaging Tips