Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is jar ignoring my manifest?

Tags:

java

jar

manifest

I tried to create an executable jar using this command:

jar -cvfm h.jar Manifest.mf Whatever1.class Whatever2.class

The manifest contains this:

Main-Class: Whatever1

But if I try to run the jar, I get: Failed to load Main-Class manifest attribute from my.jar. I extracted the jar, and I saw that the contents of it's manifest were this:

Manifest-Version: 1.0
Created-By: 1.6.0_18 (Sun Microsystems Inc.)

Why was my manifest ignored?

EDIT: I know that using the -e flag I can specify an entry point, and jar will generate a correct manifest, but I'd like to know how to make this version work.

like image 765
Geo Avatar asked Jan 30 '10 19:01

Geo


People also ask

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.

What does no main manifest attribute mean?

Unable to execute jar- file: "no main manifest attribute." The above error message is thrown because of a missing entry of Main-Class in MANIFEST. MF file. You may encounter this problem in any configuration-based Java project.

What is the use of manifest file in jar?

What gives a JAR file this versatility? The answer is the JAR file's manifest. 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.


2 Answers

Add a line break after the last line of Manifest.mf

like image 91
axtavt Avatar answered Oct 11 '22 19:10

axtavt


I've noticed that not having a newline at the end of the manifest file causes this problem at times. See if adding a new line at the end of the manifest file helps.

like image 2
Chandra Sekar Avatar answered Oct 11 '22 19:10

Chandra Sekar