Return to site

🚀📦 SKINNY JAR VS FAT JAR: REDUCING DEPENDENCY RELOADS IN JAVA DEPLOYMENTS

· java

When packaging a Java application, you often choose between Fat JARs and Skinny JARs.

The difference is not only about artifact size — it is mainly about how often dependencies need to be transferred, rebuilt, and loaded.

In many environments, dependencies change rarely, while application code changes very frequently.


Section image

🔸 TLDR

  1. ▪️ Fat JAR = app + dependencies bundled together
  2. ▪️ Skinny JAR = dependencies separated from app code
  3. ▪️ Dependencies change rarely
  4. ▪️ Separating them avoids reloading the same libraries repeatedly

🔸 WHAT IS A FAT JAR?

A Fat JAR (Uber JAR) packages your application and all its dependencies into one file.

Frameworks like Spring Boot commonly use this approach.

  1. ▪️ All libraries bundled in one artifact
  2. ▪️ Easy execution with java -jar
  3. ▪️ Very portable deployment unit
  4. ▪️ Larger artifact size

Example tools that create Fat JARs:

  1. ▪️ spring-boot-maven-plugin
  2. ▪️ maven-shade-plugin
  3. ▪️ maven-assembly-plugin

Example:

Everything is inside the JAR, so the JVM loads all dependencies from it.

🔸 THE LIMITATION OF FAT JARS

The issue appears during build and deployment cycles.

Even if you change one class, the whole artifact changes.

That means:

  1. ▪️ dependencies are rebuilt into the artifact
  2. ▪️ dependencies are transferred again
  3. ▪️ dependencies are reloaded again

Even though they didn’t change.

In large systems or CI/CD pipelines, this can mean repeatedly shipping the same libraries dozens of times.

🔸 WHAT IS A SKINNY JAR?

A Skinny JAR separates the application code from its dependencies.

  1. ▪️ The JAR contains only application classes
  2. ▪️ Dependencies live in a separate lib directory
  3. ▪️ The JVM loads them through the classpath

Example:

Structure:

Now:

  1. ▪️ application code changes often
  2. ▪️ dependencies remain stable

So they don’t need to be rebuilt or reloaded every time.

🔸 WHY SOME TEAMS PREFER SKINNY JARS

Separating dependencies allows them to be loaded and distributed less frequently.

Benefits include:

  1. ▪️ Dependencies reused across deployments
  2. ▪️ Smaller artifacts for each release
  3. ▪️ Faster CI/CD pipelines
  4. ▪️ Reduced network transfers
  5. ▪️ Better caching in container images

In short:

👉 Load dependencies once, update the app many times.

🔸 TOOLS THAT SUPPORT THIS APPROACH

Some Maven tools help externalize dependencies.

Examples:

  1. ▪️ maven-dependency-plugin (copy dependencies to /lib)
  2. ▪️ maven-assembly-plugin (custom distributions)
  3. ▪️ SlimFast Maven Plugin (store dependencies externally, e.g. S3)

Tools like SlimFast push the idea further by allowing dependencies to be stored once and reused across deployments, avoiding repeated loading of identical libraries.

🔸 TAKEAWAYS

  1. ▪️ Fat JARs maximize simplicity and portability
  2. ▪️ Skinny JARs optimize build and deployment cycles
  3. ▪️ Separating dependencies allows them to be loaded less often
  4. ▪️ Tools like SlimFast push this optimization further

Both approaches still coexist depending on deployment strategy and infrastructure.

#Java #Maven #SpringBoot #DevOps #JavaDevelopment #BuildTools #Microservices #SoftwareEngineering #BackendDevelopment

Go further with Java certification:

Java👇

Spring👇

SpringBook👇

JavaBook👇