JAR vs fat/uber JAR



 JAR  vs fat/uber JAR


01.By default, when you build a regular JAR with Maven or Gradle, your code is packaged inside the JAR, but the dependencies (external libraries) are NOT included inside the JAR itself.


02. This means, on the server where you deploy, you also need to have those dependency JARs available in the classpath for your application to run correctly.


03. However, for easier deployment, many projects use a “fat” or “uber” JAR (sometimes called a shaded JAR). This is a special kind of JAR that packages all your project classes AND all dependency classes into a single JAR file.


04. Tools like Spring Boot’s Gradle or Maven plugins can create such fat JARs using the bootJar task. That way, you only deploy one big JAR, and it has everything needed inside.

Extra:

When you build a JAR file using Gradle, the Gradle build files themselves (like build.gradle or settings.gradle) are NOT included inside the JAR. The JAR contains only


Here’s how usually works when Jenkins and your application run on different servers:

  • Jenkins build JAR or fat/uber JAR. If it is JAR, dependencies should have in application.
  • Modern setups create fat JARs (using Gradle's bootJar in Spring Boot or the Maven Shade plugin) so deployment is simpler


You are deploying two separate applications (X and Y) on the same server.

Both applications use a common library A, but:

You are not using fat JARs.

S0, heavy usage of library A in app X could slow down app Y, since it also uses the same library?


Extra:

  • In Java, dependencies are loaded into the memory (JVM) of each application separately.
  • Even if both apps use the same JAR, each JVM maintains its own copy in memory.


===

Repository : GitHub Packages, Artifactory, Nexus, or even a local Maven repo and etc

===

Comments

Popular posts from this blog

Database - Topics

02. Spring – Creating spring project clone it with GIT step by step.