Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy WAR or "fat" JAR?

Tags:

I'm noticing a lot of projects (DropWizard, Grails, etc.) starting to embrace the notion of a "fat" JAR (using an embedded web server like Jetty or Tomcat) vs. the traditional WAR deploy. Both methods involve a single JVM process (i.e. no matter how many WARs are deployed to Tomcat, it's all the same JVM process).

Under what circumstances is either deployment method preferable over the other?

like image 231
AdjustingForInflation Avatar asked Apr 15 '14 16:04

AdjustingForInflation


People also ask

Is jar or WAR better?

JAR files allow us to package multiple files in order to use it as a library, plugin, or any kind of application. On the other hand, WAR files are used only for web applications. The structure of the archives is also different. We can create a JAR with any desired structure.

What is a war file vs jar?

A JAR file is a file with Java classes, associated metadata and resources such as text, images aggregated into one file. A WAR file is a file that is used to distribute a collection of JAR files, JSP, Servlet, XML files, static web pages like HTML and other resources that constitute a web application.

What is the difference between a jar and WAR Distribution in spring boot Linkedin?

jar is Java Application Archive that runs a desktop application on a user's machine. A war file is a special jar file that is used to package a web application to make it easy to deploy it on an application server. Show activity on this post. Simple and easy answer.

What is a fat jar?

An uber-JAR—also known as a fat JAR or JAR with dependencies—is a JAR file that contains not only a Java program, but embeds its dependencies as well. This means that the JAR functions as an “all-in-one” distribution of the software, without needing any other Java code.


1 Answers

Here are some reasons:

In favor of JAR:

  1. Simple to build and deploy.
  2. Embedded servers like Jetty are easy to operate.
  3. Applications are easy for users to start and they can run on their personal computers too, because they are lightweight.
  4. Starting and stopping applications will require less knowledge than managing web servers.

In favor of WAR or EAR:

  1. The server would provide features like deployment, restart, security and so on for multiple web applications simultaneously.
  2. Perhaps a separate deployment team can handle the starting and stopping of apps.
  3. If your supervisors like to follow rules, they will be happy to find that you are not breaking them.

Having said this, you can always provide 2 or 3 types of executables to cater to all needs. Any build tool makes this easy.

like image 193
wavicle Avatar answered Jan 18 '23 13:01

wavicle