How do I specify a main class in the manifest of my generated jar file?
Author: Deron Eriksson
Description: This tutorial describes how to specify a main class in the MANIFEST.MF file that gets automatically generated for a maven jar project.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)

In JavaSW, an executable jarW file specifies its main class in the MANIFEST.MF file in that jar file. For a mavenSW project that features "jar" packaging, we can specify the main class for the MANIFEST.MF file by specifying it in our pom.xml, as shown here:


<project xmlns="" xmlns:xsi=""

This specifies that the com.maventest.App class in the project is the main class that should be executed if someone attempts to execute the jar file. Additional options that can be configured for the Maven Archiver can be found at

If we perform a "mvn clean package" to build the project's jar file and then examine the MANIFEST.MF file that is generated in the jar file at META-INF/MANIFEST.MF, we see that it contains the following:

MANIFEST.MF file in generated jar file

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: Cakes
Build-Jdk: 1.6.0_04
Main-Class: com.maventest.App

I'll open a command prompt and go to the directory containing the jar file. If I attempt to execute the generated jar file via "java -jar aproject-1.0-SNAPSHOT.jar", we see the "Hello World!" message that is output to the console as a result of the execution of com.maventest.App.

java -jar aproject-1.0-SNAPSHOT.jar