Preface
I recently started learning Java for upcoming projects. The best way to learn a language is to build something, so I created a Telegram bot and explored how Maven packages applications.
Fat vs. Thin JAR
- Fat JAR (Uber‑Jar): all classes and dependencies bundled into one large file—easy to deploy but big.
- Thin JAR: only compiled classes included; dependencies remain external, saving space at the cost of management complexity.
Project Setup
A project skeleton is generated with maven-archetype-quick. The structure resembles:
| |
Bot.java handles Telegram API interactions while Main.java launches the bot.
Packaging
Fat JAR with Maven Shade
Add the maven-shade-plugin to pom.xml to create a single executable JAR:
| |
Thin JAR
For a slimmer artifact, package only project classes and supply dependencies on the classpath at runtime.
Running the Bot
Build the project with mvn package and run the resulting JAR:
| |
Conclusion
Exploring Maven’s packaging options clarified the difference between Fat and Thin JARs and helped me publish a working Telegram bot.
