Generate Fat Jar or Uber Jar from Source

In this article we will learn how to generate a Fat Jar or Uber Jar from Source Code.

A fat jar or an uber jar is a jar file which contains all of its dependencies. Therefore you don’t need to download external dependencies while running the jar file.

Prerequisite Knowledge

To understand this upgrade guide you dont need to be an expert but having some basic knowledge of linux terminal commands, Postgres Database and java will help you.

Steps for Creating a Fat Jar

1. Install OpenJDK 8
2. Install GIT version control system
3. Install Maven
4. Clone the github repository
5. Generate Fat Jar

Let us begin the step by step Upgrade Guide for Nearby Shops API Backend

Step 1 : Install OpenJDK 8

Our API Runs on Java therefore we need JDK on our system. We recommend you to install OpenJDK-8 the open-source version of JDK to stay on the safe side of licensing issues.

To install OpenJDK 8

Type the following commands on your terminal

    sudo apt-get udpate
    sudo apt-get install openjdk-8-jdk

in order to verify jdk has been installed type type “java -version”

    java -version

The above command gives the following output which indicates that Java 8 has been installed

    openjdk version “1.8.0_151”
    OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
    OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

Step 2 : Install GIT Version Control System

Source Code for Nearby Shops API is hosted on Github and we will be cloning the git repository. For cloning the repo we will require GIT. Therefore if GIT is not on your system. Please install GIT.

Step 3 : Install Maven

Maven is a build System for Java. It assembles the source code and generates the Executable Jar file. We are going to generate an Executable Jar file from the latest Source code therefore we will require Maven also. To install maven type the following commands on your terminal

    sudo apt-get update
    sudo apt-get install maven

To verify that maven has been installed type

    mvn -version

The above command should give the following output on your terminal which verifies that maven is installed.

    Apache Maven 3.3.9
    Maven home: /usr/share/maven
    Java version: 1.8.0_151, vendor: Oracle Corporation
    Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
    Default locale: en_IN, platform encoding: UTF-8
    OS name: “linux”, version: “4.4.0-112-generic”, arch: “amd64”, family: “unix”

Step 4 : Clone the Repository

Create a folder where you will clone your repository.

    cd /
    mkdir nearbyshops
    cd nearbyshops

Go to the source code and head over to the nearby shops api github repo and copy the link for cloning the repo. Now clone the repository by typing the following command.

    git clone

Step 5 : Generate Uber Jar

CD inside the cloned repository folder. ( See the commands below)

    /nearbyshops# ls
    nearbyshops# cd Nearby-Shops-API

When you type “ls” on your command line inside the cloned repository folder. You should see the following files and folders.

    /nearbyshops/Nearby-Shops-API# ls
    LICENSE pom.xml src target nearbyShopsAPI.iml

When you are inside the directory which contains the pom.xml file. You can now type the following commands to generate the jar file

    cd /nearbyshops/Nearby-Shops-API
    mvn install

maven looks for a pom.xml file in order to generate the Jar file. When you run the mvn install command it will take around 5 minutes to download all the dependencies. Time depends upon the speed of your internet connection. So keep patience.


“mvn install” command downloads all the dependencies and generates a fat jar (uber jar). The fat jar is a jar file which is self contained and does not need to download any dependencies to run. after all the process is complete you can find the jar file generated inside the “target” folder.