"No Main Manifest Attribute" in ----.jar Netbeans

Hope there is a problem in your manifest file. Some basic checks might solve your problem.

  • it should under /META-INF/MANIFEST.MF
  • Content should have Main-Class:com.MyCompany.App

If you are using any IDE, there should be an option to export project as runnable jar, you can make use of that to let the IDE take care of correct manifest.

From command line jar cfm filename.jar Manifest.txt com/MyCompany/*.class which generates the Manifest file with following contents

Manifest-Version: 1.0
Created-By: 1.6.0 (Sun Microsystems Inc.)
Main-Class: com.MyCompany.App

And then you can run jar command java -jar fileName.jar.

These type of problems are trivial but kills lot of time, just ensure your contents and location of the file is correct.


You need the maven-jar-plugin (see Maven's example). This plugin will create the required entries in the manifest file when the project is built.

<project>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>fully.qualified.MainClass</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

You need the version, otherwise, the project won't build. The fully.qualified.MainClass starts at the package hierarchy.