invalid header file while using jar for archiving

When i use this cmd line : jar cmf arshad.mf ars.jar *.class i get this error :

invalid header field name:Manifest-version

This is my manifest file :

Manifest-Version: 1.0
Main-Class:t

i made the manifest file with notepad in UTF-8 encoding - is there any problem with the manifest ?

Answers


Add a space after the colons:

Manifest-Version: 1.0
Main-Class: t

Yes,it is true.

A common mistake people make when writing their manifest files for jar's is that they don't put spaces after their colons. I don't know, based on what you wrote here, if that's it or not but give it a try.

Example:

Main-Class:someClass //wrong
Main-Class: someClass //correct

Also, your manifest file must be saved as UTF-8. You're not necessarily safe writing it on MS Notepad and saving as UTF-8 encoding. This post has some good details:

Invalid Header Field Name when adding manifest to JAR using Eclipse

Notepad adds some bytes onto the front to broadcast the endian-ness of the data. This will break the jar command. A decent solution is to not use Notepad and download Notepad++. In Notepad++ you select 'encoding' from the top bar, and select 'UTF-8 Without BOM'. Saving your manifest file with this setting applied should solve the problem. If there are no others.


Need Your Help

Abort Xhr on cujojs rest.js

javascript ajax rest request xmlhttprequest

I'm using cujojs/rest to send requests to my (laravel) API. I'm looking for a way to cancel requests that are not over when a new one comes in.

What are the commands to use an openssl connection to pop3?

pop3

It is possible to get access to a text version of the email, by typing in the terminal: