Reputation: 2500
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?
Upvotes: 8
Views: 10146
Reputation: 166
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
Upvotes: 1
Reputation: 111
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.
Upvotes: 3
Reputation: 13475
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.
Upvotes: 5
Reputation: 201409
Try this jar -cmvf MANIFEST.MF build/tasks.jar build\classes\ua\sumdu\j2se\studentName\tasks\*.class
Upvotes: 2
Reputation: 33936
Use the M
option to disable the default META-INF/MANIFEST.MF
, or use the m
option to explicitly specify your own (documentation).
Upvotes: 11