Spring Boot JAR Execution Flow: Main-Class in MANIFEST.MF

🚀 Ever wondered how Spring Boot knows which class to run when you execute a JAR? When you run: 👉 java -jar your-app.jar The JVM doesn’t magically detect your main class. It simply follows instructions from a file inside the JAR 👇 📦 META-INF/MANIFEST.MF Spring Boot (via spring-boot-maven-plugin) automatically generates this with: Main-Class → JarLauncher Start-Class → Your actual application class 💡 Execution Flow: JVM → reads MANIFEST.MF → starts JarLauncher → loads your main class → runs main() ⚙️ How do you create this JAR? In IntelliJ (Maven project): Go to Maven → Lifecycle → package This runs mvn clean package Your executable JAR is created in target/ ⚠️ Important: Without spring-boot-maven-plugin, your JAR won’t be executable (java -jar will fail). 💡 Simple way to remember: 👉 JVM doesn’t guess the main class — it reads it from MANIFEST.MF. Have you ever faced the “no main manifest attribute” error? 😅 #SpringBoot #Java #Backend #SoftwareEngineering #DeveloperTips #JavaDeveloper

To view or add a comment, sign in

Explore content categories