Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MANIFEST.MF: difference between Main-Class and Start-Class

In a project I am taking over, I found a Jar file with the following MANIFEST.MF file:

Manifest-Version: 1.0
Start-Class: com.xxx.Application
Spring-Boot-Version: 1.2.7.RELEASE
Main-Class: org.springframework.boot.loader.JarLauncher

What is the difference between Start-Class and Main-Class?

like image 862
stefan.m Avatar asked Jan 04 '16 14:01

stefan.m


People also ask

What is start class in POM XML?

The main class can be defined as a start-class element in the pom.xml's properties section: <properties> <!-- The main class to start by executing "java -jar" --> <start-class>com.baeldung.DemoApplication</start-class> </properties>

Where should manifest MF be?

The manifest file is named MANIFEST. MF and is located under the META-INF directory in the JAR. It's simply a list of key and value pairs, called headers or attributes, grouped into sections.

What is manifest MF in java?

mf extension is a Java Manifest file that contains information about the individual JAR file entries. The MF file itself is contained inside the JAR file and provides all the extension and package-related definition. JAR files can be produced to be used as an executable file.


1 Answers

This is a feature of Spring Boot. Main-Class defines that Spring Boot's org.springframework.boot.loader.JarLauncher class will be launched in a first step.

In a second step, org.springframework.boot.loader.JarLauncher will launch the main method of the class that is given to the Start-Class property - in this case, com.xxx.Application.

For details, see https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html.

like image 152
stefan.m Avatar answered Oct 21 '22 23:10

stefan.m