FAT Jar [#-#]น้องจาร์อ้วน
Getting a little knowledge about the Fat jar.
What is a FAT JAR ? !!!!! => It’s a single JAR file that contains compiled classes files, resources and packed it together (included all dependencies files and all dependencies libraries).
Advantage : All resource files are in a packed and its also avoids dependency version issues.
Disadvantage: Use “Bootstrap” classloader to enable Java to load classes from the wrapped JAR files. For the development, debugging class loader is more complex. For loading resouces, its used “getResource()” command to
get the resouces when loading a lot of jars can be issues , due to locking inside URLClassPath.
How to build a FAT JAR ? => It has many build systems to buuild a fat jar such as Gradle , Apache Maven, Apache Ant and etc.
The example to create a Fat jar
(Note: spring-boot application)
The structure of project is diplayed below :
- ${Project}/src/main/java/
- ${Project}/src/main/resources/
- ${Project}/src/test/java/
1. We added "Spring-boot-maven-plugin", But we copied all files to build in the main project. 
2. We use a "Maven Assembly Plugin" to pack all a project and all dependencies from (1) to build a fat jar file.“Maven Assembly Plugin” is bind to the Maven’s packaging phase, to process to the final jar.So, the build command is "mvn clean install"

Why call a “FAT JAR” ?
The Qualifiers (in increasing order of logical size):
- Skinny — Contains ONLY the bits you literally type into your code editor, and NOTHING else.
- Thin — Contains all of the above PLUS the app’s direct dependencies of your app (db drivers, utility libraries, etc).
- Hollow — The inverse of Thin — Contains only the bits needed to run your app but does NOT contain the app itself. Basically a pre-packaged “app server” to which you can later deploy your app, in the same style as traditional Java EE app servers, but with important differences, we’ll get to later.
- Fat/Uber — Contains the bit you literally write yourself PLUS the direct dependencies of your app PLUS the bits needed to run your app “on its own”.
The reference according to https://dzone.com/articles/the-skinny-on-fat-thin-hollow-and-uber
