Home >Web Front-end >JS Tutorial >WAR, JAR, EAR, and TAR - Archive file formats
War, JAR, EAR and TAR are different archive file formats. WAR is used to pack the Java Web application, including Servlet, JSP and Web resources, which are deployed on servers such as Tomcat. JAR package Java class and library for independent applications or dependencies. EAR is used for enterprise -level Java EE applications, combining WAR, JAR, and EJB modules and deployed on servers such as JBoss or Glassfish. TAR is a general archive format, which is used to store any type of file, which is usually used with compression (such as .tar.gz). Each format is for specific cases: WAR is used for web applications, JAR is used for library, EAR is used for enterprise applications, TAR is used for general file archives.
The following is a detailed comparison of war, jar, ear, and tar files:
Content:
Servlet, JSP files, HTML, CSS, JavaScript.
Structure:
Key: Web applications specific packaging.
<code>MyApp.war ├── WEB-INF/ │ ├── web.xml │ ├── lib/ │ └── classes/ ├── index.html ├── styles.css └── script.js</code>
jar (java archive)
Compiled .class file.
metadata (in Meta-inf/Manifest.mf).
The sharing library of other applications (for example, the dependency item in Maven/Gradle).
Key: Java applications or libraries are universal.
<code class="language-bash">jar cf MyApp.jar -C compiled_classes_directory/ .</code>
Ear (Enterprise Archive)
<code>MyApp.jar ├── META-INF/ │ └── MANIFEST.MF ├── com/ │ └── example/ │ └── MyClass.class</code>
Usage: It is used to pack corporate applications (multi -module applications) in the Java EE.
deployment descriptive, such as Application.xml.
ENB (Enterprise Java Beans) module.
Tar (Tape Archive)
Uses: A general archive format is not limited to Java.
<code>MyApp.ear ├── META-INF/ │ └── application.xml ├── MyWebApp.war └── MyEJBModule.jar</code>
Content: Any type of file (text, binary files, images, etc.).
Usually used with compression (for example .tar.gz).
Create command:
War: Used for web applications. Jar: Used for library or independent Java applications. EAR: For enterprise -level multi -module applications. TAR: For general file archive (non -Java -specific).
The above is the detailed content of WAR, JAR, EAR, and TAR - Archive file formats. For more information, please follow other related articles on the PHP Chinese website!