Roufid

No main manifest attribute, in jar

Java

Problem

Sometimes you face the following error while runing an executable jar :

No main manifest attribute, in “<APP_NAME>.jar”

Solution

Consider that the the fully qualified name of your Main class is com.roufid.tutorials.AppTest

Take time to understand !

Since your are running an executable jar file, Java will look for the manifest MANIFEST.MF located under META-INF/ which contains information about the files packaged.

Java must know the main class to run. This information was missing in the MANIFEST.MF. Below the content of this file before adding the maven-jar-plugin :

There is no mention of a Main-Class !

We used maven-jar-plugin to handle jar content and manifest configuration, specially adding a Main-Class property to MANIFEST.MF file to specify the project main class. Below the aim of the property :

The manifest classpath produced using the above configuration would look like this:

References