Deployment File Types

JAR File

JAR[Java Archive ] files r combination of .class files.All these class files or bytecodes r compressed to form a .jar files. In short these jar files r compressed format of compiled java programs.So, these r .class files along with some other files & its meta data packaged together in the form of zip file.
A jar file encapsulates 1 or more java files {.class files} , a manifest & a descriptor. In short it contains compressed version of java class fils,audio,image files or directories.
________
These jar files r needed to be used by other projects.We can easily distribute our source code to any1.These jar files can also be used for direct execution of our java programs without the use of any IDE.
To execute a jar file from cmd ->
cd {path of that jar}
Java -jar {my jar file name}
_____________
On decompressing a jar file we'll get a package containing .class file + metaInf file (which is the information about the main class).
The META-INF/MANIFEST.MF file may contain additional metadata about the files stored in the archive.
As we compile our java program of .java to .class file .Similarly, we can convert our .class file back to the .java files using java decompiler.We can also use this .class file as a Plugin in eclipse.

WAR File

WAR files is a combination of web related pages such as html,jsp,servlet,css,js etc.War is the archive file for web application.
a WAR file (Web Application Resource or Web application ARchive) is a file used to distribute a collection of JAR-files, JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static web pages (HTML and related files) and other resources that together constitute a web .
A WAR file is used to deploy a Java EE web application in an application server. Inside a WAR file, all the web components are packed into one single unit. These include JAR files, JavaServer Pages, Java servlets, Java class files, XML files, HTML files, and other resource files that we need for web applications.
These archive files have the . war extension and are used to package web applications that we can deploy on any Servlet/JSP container. Advantage of using WAR Files -
  • Easy testing and deployment of web applications ·
  • Easy identification of the version of the deployed application

EAR File

An EAR file is a critical piece in deploying a service application to a production server. An enterprise archive (EAR) file is a compressed file that contains the libraries, enterprise beans, and JAR files that the application requires for deployment.
EAR Is the superset of jar as well as war files.Jar files are the subset of war and war files are the subset of EAR.
Difference between WAR,JAR & EAR
An EAR file requires a fully Java Platform, Enterprise Edition (Java EE)- or Jakarta Enterprise Edition (EE)-compliant application server, such as WebSphere or JBoss, to run. A WAR file only requires a Java EE Web Profile-compliant application server to run, and a JAR file only requires a Java installation.

TAR File

A tar (tape archive) file format is an archive created by tar, a UNIX-based utility used to package files together for backup or distribution purposes. It contains multiple files (also known as a tarball) stored in an uncompressed format along with metadata about the archive. Tar files are not compressed archive files.
Advantages of using TAR Files
  • Tar, when it comes to compression, has a compression ratio of 50%, which means it compresses efficiently.
  • Drastically reduces the size of packaged files and folders.
  • Tar does not alter the features of files and directories.
  • Tar is widely available across most common Linux versions.