Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jar ignores my manifest

Jar is ignoring my manifest file and replaces it with auto-generated manifest.

my manifest is :

Manifest-Version: 1.0 
Created-By: Student Name 
Main-Class: ua.sumdu.j2se.studentName.tasks.PrintMonth

(with empty line)

cmd:

jar -cvf build/tasks.jar MANIFEST.MF build\classes\ua\sumdu\j2se\studentName\tasks\*.class

and as a result if I open jar file with winrar, there would be:

build
META-INF
MANIFEST.MF - my manifest

if i place manifest into META-INF and execute

jar -cvf build/tasks.jar META-INF/MANIFEST.MF build\classes\ua\sumdu\j2se\studentName\tasks\*.class

in my META-INF folder will be 2 manifests.

What's going on?

like image 254
ovnia Avatar asked Nov 23 '13 00:11

ovnia


4 Answers

Use the M option to disable the default META-INF/MANIFEST.MF, or use the m option to explicitly specify your own (documentation).

like image 168
Brett Kail Avatar answered Oct 17 '22 22:10

Brett Kail


One more thing: the order of jar options matters. If you put m first, f second, then jar arguments need to go in the same order: manifest-file jar-file, and vice versa.

The line in jar help I missed first:

The manifest file name, the archive file name and the entry point name are
specified in the same order as the 'm', 'f' and 'e' flags.
like image 22
Victor Sergienko Avatar answered Oct 17 '22 23:10

Victor Sergienko


Also check that the last line of your manifest ends with a new line or carriage feed. I did not have a new line at the end of my manifest and this made it appear to be omitted.

I see you have (with empty line). But I arrived at this answer without one.

like image 3
NeverCast Avatar answered Oct 18 '22 00:10

NeverCast


Try this jar -cmvf MANIFEST.MF build/tasks.jar build\classes\ua\sumdu\j2se\studentName\tasks\*.class

like image 2
Elliott Frisch Avatar answered Oct 17 '22 23:10

Elliott Frisch