In fact, both the jar package and the war package can be regarded as compressed files, can be opened with decompression software, jar packages and war packages exist because, for the deployment and release of the project, usually the project packaging, usually in the packaging of the deployment, will be included in the deployment of relevant information.
This package actually compresses the code and dependencies into a file with the suffix. jar and. War, which is what we call the jar package and the war package. However, this "compress package" can be used directly by the compiler, put the war package under the WebApp of the Tomcat directory, and the Tomcat server can use the war package directly when it is started. The usual tomcat practice is to unzip, compile the code inside, so when the file is a lot, Tomcat will start very slowly. With so much to say, there is no difference between a jar package and a war package. The jar package is a Java package, the war package can be understood as Javaweb hit the package, this will be more good to remember.
The jar package is only packaged in Java-written items, with only the compiled class and some deployment files. The war package contains everything, including written code compiled into the class file, dependent packages, configuration files, all Web pages, including html,jsp and so on.
A war package can be understood as a Web project, which is everything in the project. When do I use a jar package or war package? When your project is not fully completed, it is not appropriate to use the war file, because your class will often change because of debugging, such as to delete, create a war file is not convenient, back and forth to modify, packaging, it is best that your project has been completed, do not modify the time, then make a war bag it, At this point a war file is equivalent to a Web application, and a jar file encapsulates a class and some related resources into a package for easy reference in the program.
The difference between a jar package and a war package in Java is