Java - Archive File Formats (JAR - WAR - EAR)

Differences

JAR Files

WAR Files

EAR Files

Java Archive

Web Application Archive

Enterprise Application Archive

a file containing:

  • compiled Java source code
  • manifest file
  • XML-based configuration data
  • JSON-based data files
  • associated resources (text, images, etc)

a standard JAR containing:

  • JAR files
  • JSP files
  • Servlet files
  • XML files
  • static pages (HTML, JavaScript, CSS)

a standard JAR file that:

  • represents the modules of the application
  • metadata directory (i.e. META-INT) which contain one or more deployment descriptors

*.jar

*.war

*.ear

used for running a desktop application on a user’s machine’s JRE

can also start an embedded web server (e.g. with Spring Boot)

used for deploying a web application inside an application server

used for deploying different modules onto an application server simultaneously