4

I have a maven project. The application has a class with main method. I am creating a jar file for this application which will be called by a batch. The batch will call the jar file and theoretically it will look for class with main method. But the application is missing manifest file. So I need to create one to make the jar run.

I am not able to find how to create manifest file using maven. Do I need to create the META-INF directory and Manifest.mf file manually and fill it or is there any automatic way using Maven?

romil gaurav
  • 1,121
  • 11
  • 23
  • 43

1 Answers1

6

Use maven-jar-plugin:

 <plugin>
              <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>2.4</version>
                        <configuration>
                            <archive>
                                <!-- Configures the content of the created manifest -->
                                <manifest>
                                    <!-- Adds the classpath to the created manifest -->
                                    <addClasspath>true</addClasspath>
                                    <!-- Specifies that all dependencies of our application are found -->
                                    <!-- Configures the main class of the application -->
                                    <mainClass>xxx.zzz.yyy.MainClass</mainClass>
                                </manifest>
                            </archive>
                        </configuration>

                    </plugin>
halfer
  • 19,824
  • 17
  • 99
  • 186
Hisham Khalil
  • 1,054
  • 8
  • 9