Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong Manifest.mf in IntelliJ IDEA created .jar

I'm trying to package a project using OptaPlanner 6.0.1 libraries into a .jar through IntelliJ IDEA's jar artifact but instead of my manifest.mf containing the standard

Manifest-Version: 1.0 Main-Class: a.b.c.app 

the jar uses the one supplied in ecj-3.7.2.jar, one of OptaPlanner's supporting libraries:

Manifest-Version: 1.0 Build-Jdk: 1.6.0_26 Built-By: ibrandt Created-By: Apache Maven Archiver-Version: Plexus Archiver 

Because of this, a "no main manifest attribute, in appname.jar" error happens when trying to run the app. If I manually replace the manifest in .jar file with mine everything works correctly. Is there anything I can do to fix this?

I keep the libraries in a separate /lib directory and they were added to the root of jar artifact as Extracted Directory, IntelliJ IDEA is v13.0.1.

like image 594
grudolf Avatar asked Jan 06 '14 14:01

grudolf


People also ask

How do I change the manifest of a JAR file?

To modify the manifest, you must first prepare a text file containing the information you wish to add to the manifest. You then use the Jar tool's m option to add the information in your file to the manifest. Warning: The text file from which you are creating the manifest must end with a new line or carriage return.

What is manifest MF in JAR?

The manifest is a special file that can contain information about the files packaged in a JAR file. By tailoring this "meta" information that the manifest contains, you enable the JAR file to serve a variety of purposes.

How manifest MF file is created?

Manifest. MF contains information about the files contained in the JAR file. These are entries as “header:value” pairs. The first one specifies the manifest version and second one specifies the JDK version with which the JAR file is created.

Where is the manifest file in JAR?

The manifest file is named MANIFEST. MF and is located under the META-INF directory in the JAR. It's simply a list of key and value pairs, called headers or attributes, grouped into sections.


1 Answers

I had the same problem.

Make sure your MANIFEST.MF is in:

src/main/resources/META_INF/ 

NOT

src/main/java/META_INF/ 
like image 75
jamhan Avatar answered Oct 21 '22 15:10

jamhan