Q:

Missing Main-Class attibute in MANIFEST.MF in Maven generated jar file

I am currently experimenting with Maven in Eclipse (m2e-Plugin) and tried to build and run the Hello World example project. However, when launching the generated jar, nothing happens. I checked the MANIFEST.MF and noticed that the Main-Class attribute was missing. After adding the attribute, the jar could be launched.
Why does Maven not add this attribute?

A:

Have a look at this link:
https://maven.apache.org/shared/maven-archiver/examples/classpath.html#aAdd
You can find there how to configure your maven project to run specific class. You have to add maven-jar-plugin configuration with mainClass defined.
<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    ...
    <configuration>
      <archive>
        <manifest>
          <addClasspath>true</addClasspath>
          <mainClass>fully.qualified.MainClass</mainClass>
        </manifest>
      </archive>
    </configuration>
    ...
  </plugin>
</plugins>

