nokia error code 217 - jar manifest end of line - java

I have developed a J2ME application with J2ME Polish. Nokia now validate contents that will be submitted to the store, the challenge is that during validation of my JAR and JAD files, I get Error 217 - The JAR manifest does not end with a new line
I checked my JAR manifest and finds out that it is ending with a new line. Is anyone having any suggestions or solutions?

Double check that there are no invisible characters like whitespace or tab at the last line of the manifest.
If manifest has a newline indeed, error message apparently means a bug in this Nokia device.
Still, it is possible that your manifest has something wrong and that Nokia only used incorrect message to indicate some other problem in it. Getting messages like this, make sure that your manifest conforms to respective sections of JAR file Specification (available online), particularly:
Manifest Specification
Notes on Manifest and Signature Files
First I'd check is that manifest lines do not exceed "72 bytes (not characters), in its UTF8-encoded form".
Another thing worth trying is to experiment with various styles of line endings of those specified: CR LF | LF | CR. In your IDE / build there could be a setting to manage that, look for something called like "DOS / Unix / Mac line breaks". Specification states that all these are OK, but you better account for a chance of bug in the device not being able to recognize particular style line breaks.
Also consider checking / asking at Nokia forums for this might be a known issue with particular device.

Finally got this, i used the jar tool provided by the java sdk to extract the midlet from the jar file like this:
jar xf myjarfile.jar META-INF/MANIFEST.MF
then edited the file in a text editor and updated the manifest in the jar file
jar umf META-INF/MANIFEST.MF myjarfile.jar
Thanks for suggestions guys.

optionally you can open your jar file using winrar software then you can access the manifest from the META - INI file.from this you can edit it using the text editor after which you can save CAUTION:after saving note that the size is going to change so make sure you check the size of the jar after you have edited , by right clicking then view properties.check the size then change it accordingly to jad file by opening your jad file in a text editor
thats it:-0

Related

Java System Level deployment Malformed deployment.config file

I am trying to install Java jre 1.8u31 from the command line. I am using system level install configuration by using the deployment.config file and deployment.properties.
I have tried the following:
deployment.system.config=file\:C\:/WINDOWS/Sun/Java/Deployment/deployment.properties
deployment.system.config.mandatory=true
I have also tried the following
deployment.system.config=file:///C:/Windows/Sun/Java/Deployment/deployment.properties
deployment.system.config.mandatory=true
I have swapped the entries around in hopes of getting a better error describing what I am doing wrong. I have also made the first line blank in the deployment.config file. I have googled and tried all examples I could find online. In all the cases, I am being presented a dialog box with an error that states the deployment.config file's line 1 is malformed.
Any suggestions would be greatly appreciated.
Russ
I have tried all of these formats:
The path you have given should be in below format
deployment.system.config=file:/C:/Windows/Sun/Java/Deployment/deployment.proper‌​ties
I got the install to work correctly. What I did was put the deployment.config file in the C:\Windows\Sun\Java\Deployment directory. The property in the file was setup as so:
deployment.system.config=file\:C\:\\Sup\\Java\\UPGRADE\\Deployment\\deployment.properties
The exceptionlist file was in the same directory as the deployment.properties file.

IOException: 'Invalid header field; when creating .jar file with manifest

When I type jar cvfm file_name.jar manifest.txt *.class in command prompt I get this error:
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:410)
at java.util.jar.Manifest.read(Manifest.java:199)
at java.util.jar.Manifest.<init>(Manifest.java:69)
at sun.tools.jar.Main.run(Main.java:172)
at sun.tools.jar.Main.main(Main.java:1177)
I've never gotten this error before and I can't find anything on it, what does it mean?
Be careful about the order of the parameters:
1) jar cvmf manifest.txt some.jar package/*class
2) jar cvfm some.jar manifest.txt package/*class
Check the name of a header variable in the MANIFEST file. MANIFEST file is not correct.
This tutorial will help to identify the MANIFEST file format and related things, http://docs.oracle.com/javase/tutorial/deployment/jar/manifestindex.html
In case you land here and tried everything and still isn't getting rid of the problem, take a look if there are any accidental tabs instead of 4 spaces for indentation in the MANIFEST file.
I was using a maven pom.xml file to auto-generate the MANIFEST and the property line was too big, spanning multiple lines like this:
<Extension-List> item1 item2 item3 item4
item5 item6 item7 item8 <--- these lines are idented with tabs
item9 item10 item11 item12 </Extension-List>
this was corrupting the MANIFEST file in a very hard to see way.
Your Manifest file has to follow the required format. If you're generating the file yourself, then you should be able to figure out where you got the syntax wrong. If the manifest file was generated by some tool or process, however, you'll have to check the tool's documentation to see whether you ran into a bug in the tool.
Read carefully the first line of your manifest, for example :
Main-Class: main.HelloWorld
I had this error because I added a space like this "Main-Class :"
Maybe it is something similar.
My problem was that I had loads of dependencies on one line so I split it up using a simple Find and Replace where each JAR was on a separate line. It turns out that if you have something like:
Class-Path: dependencies/org.apache.commons.cli_1.4.jar (note the space at the end)
dependencies/org.apache.log4j_1.2.15.v201012070815.jar (note the space at the end)
You need to make sure that the line doesn't end with a space, and that the new line begins with a space, like so:
Class-Path: dependencies/org.apache.commons.cli_1.4.jar
dependencies/org.apache.log4j_1.2.15.v201012070815.jar
This problem can also occur if your MANIFEST.MF file begins with some non-printable characters. Tools like notepad and wordpad don't let you see them, so you'll swear you're file looks right and that all your headers are valid.
In my case I got the message:
java.io.IOException: invalid header field name: Built-By
The clue if you are having this situation are those characters occurring before the valid Built-By header. Those are non-printable characters that somehow got into your MANIFEST.MF file. The other clue is to open a command line, navigate to your MANIFEST.MF file and do
>cat MANIFEST.MF
□Build-BY: TSRUT
Bundle-Description: Fragment Controller.
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Notice that box character before your 1st header at the beginning of the file. If that's the case, this is the solution to your problem:
Open up your favorite editor, manual select the entire file (do not use the select-all command, as that will also select those hidden characters). Close the file. Open a new instance of your editor, paste your content, and save the new file back to your original MANIFEST.MF file. Select yes to overwrite. Then verify that those hidden character were removed from the beginning of the file.
if your manifest file is having some additional empty lines will also cause this error . Make sure to remove the additional lines.

j2me JAR Manifest, JAD File and Nokia Publish QA failure

Recently I've developed some application which is simple Weider 6 excersises browser.
I've created manually JAD file with elements from JAR manifest, however my application was revoked by Nokia Publish QA team with following reason:
Dear publisher,
While processing your content we found the following MIDlet-attributes are not present in the JAD and JAR manifest files:
Key 'MicroEdition-Profile' is not in the .jad and .jar.
Key 'MicroEdition-Configuration' is not in the .jad and .jar.
Key 'MIDlet-1' is not in the .jad and .jar.
Key 'MIDlet-Name' is not in the .jad and .jar.
Key 'MIDlet-Version' is not in the .jad and .jar.
Key 'MIDlet-Vendor' is not in the .jad and .jar.
What is really weird because my manifest looks like following:
MIDlet-Version: 1.0.0
MIDlet-Vendor: Michal Kulesza
MIDlet-Jar-URL: Weider6.jar
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-2.1
MIDlet-1: Weider6,/1.png,me.kulesza.WeiderExcercises
MIDlet-Name: Weider6
and JAD file is almost the same:
MIDlet-Jar-Size: 199784
Sealed: true
MIDlet-Version: 1.0.0
MIDlet-Vendor: Michal Kulesza
MIDlet-Jar-URL: Weider6.jar
MicroEdition-Configuration: CLDC-1.0
MicroEdition-Profile: MIDP-2.1
MIDlet-1: Weider6,/1.png,me.kulesza.WeiderExcercises
MIDlet-Name: Weider6
Did anyone of you experienced such issue?
Am I doing anything wrong or it's their fault?
You can check the JAD File online with my JAD-Checker
jadcheck.appspot.com
You should probably also include these entries:
MIDlet-Icon
MIDlet-Description
But these missing entries can not be the reason for the error report you got.
To me it looks like something went wrong during uploading. For example, an error you can easy do: select the file to upload, but not confirm it to start the actual upload.
It happen to me that when I finally saved the whole form, the files were not uploaded, the system used my old files, and the QA has reexamined my old version.
Now before I submit to QA, I always download what I have uploaded, to check that the system has really my new files.
There is an extra "verify" button. It should catch errors like this one.

Invalid Header Field Name when adding manifest to JAR using Eclipse

I'm using eclipse to develop a java applet and need to add an external jar to Class-Path in the manifest. I created the manifest file using notepad, used UTF-8 encoding and added the line break at the end, but attempting to add even a simple example manifest during jar creation results in the following error from Eclipse.
invalid header field name: ï>¿Manifest-Version
invalid header field name: ï>¿Manifest-Version
I have a feeling that it's some simple configuration issue, but I can't figure out what.
To test it, my manifest consists of the single line
Manifest-Version: 1.0
Notepad save your file with a special mark named 'BOM' at the beginning : 2 bytes (U+FEFF) which identify UTF-8 format.
You have to edit the file with Notepad++ (or vi) and encode it as UTF-8 (without BOM).
Next steps to make JARs:
Using eclipse
Using Apache ANT
Using Apache Maven
In Notepad++ , from the encoding menu , choose encode in UTF-8 without BOM .
In eclipse, right click in file properties and choose text file encoding to ISO-8859-1
Back in editor delete the special chars.

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 ?
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.

Categories

Resources