jar ignores my manifest
Asked Answered
L

5

8

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?

Luxate answered 23/11, 2013 at 0:2 Comment(0)
L
10

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

Lowelllowenstein answered 23/11, 2013 at 0:7 Comment(0)
S
5

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.
Salem answered 29/2, 2016 at 16:59 Comment(0)
E
3

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.

Equivalence answered 16/10, 2017 at 6:3 Comment(0)
H
2

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

Hydrometer answered 23/11, 2013 at 0:8 Comment(0)
T
1

Step 1.

Compile Main.java.

javac Main.java

Step 2.

Create MANIFEST.MF.

Manifest-Version: 1.0
Main-Class: Main

Step 3.

Create app.jar.

jar cmvf MANIFEST.MF app.jar Main.class

Step 4.

Run app.jar.

java -jar app.jar
Turne answered 6/2, 2020 at 9:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.