rrirower rrirower - 7 months ago 158
Java Question

Updating jar manifest file - java.io.IOException: invalid manifest format

I need to update the manifest in my jar file that I create (export) within Eclipse. I've tried to follow this explanation without success. I'm not quite sure what to specify on the command line. The Oracle web site is not too clear. I then found a post on SO that said to extract the manifest.mf file from the jar archive, update it, and add it back to the jar archive. I've tried that too, and it appears to work, however, at runtime, I get

java.io.IOException: invalid manifest format
. What is the correct way to update the manifest.mf to add new attributes? An example would be most helpful.


The links offered by Peter were partially useful. However, I was able to solve this more or less by trial and error. The Oracle docs that explain how to do this need lots of work. They lack a good example of how to proceed. Anyway, for those who run into the same issues, here's what I did. I created a text file (eg. "Manifest.txt") using Notepad that contains the manifest attributes I wanted to add/update. In creating this file, I made sure to add a new line character to the last line by pressing the key on the keyboard. Next, I created a DOS bat file to do the actual modification. Here's what it looked like...

echo Updating manifest permissions...
"C:\Program Files\Java\jdk1.7.0_25\bin\jar" -umf "c:\some folder\Manifest.txt" "C:\some folder\jartoupdate.jar"

The order of the jar arguments as they relate to the actual paths that follow on the command line is important. The links from Peter's reply pointed that part out.