Objective:
Why do you want to hit the jar bag?
1, for example, when writing a tool class library, there are more than 10 classes, each class corresponding to a class file, in order to facilitate the invocation of others, is not to be installed in a file, easy to pass and reference.
2, hit Jar package also has a benefit, that is, does not include the source file, for some confidential information of the library, jar package and code opacity is a preferred.
3, easy to deploy and reference.
There are two types of packaged jars, containing the main entry and not the main entry, which are usually tested with the main entrance. The Include main entry is also called an executable jar file.
The war is for Web projects, and the war package is also for ease of deployment.
When you package an executable jar file, there is usually a file manifest.mf that specifies the Main-class entry, which is typically placed in the root directory.
One, command line:
Second, GUI tools eclipse:
Three: Maven
This method is omitted and will be used to explain the build of Maven in the future.
Java packaging jar and war files (Eclipse)