BUG: JAR File fails on handset when built on MacOS X using Apache Ant
Summary: A jar file, when built on MacOS X with Apache Ant, fails when deployed to a handset. On Nokia Series 60 v2 phones this will pop an error on installation with the text “Invalid file”. Other handsets may show slightly different behavior. The same jar file will often run fine in an emulator such as the Sun WTK 2.2 emulation or MPowerPlayer SDK. A jar file built on Windows from the same source will deploy to the handset just fine.
Discovery: After some investigation, the difference between a jar created on MacOS X and other platforms was narrowed to the manifest file. The “Created-By:” manifest entries were the only differences. According to [Sun’s versioning documentation], the Created-By entry is generated by the jar tool to indicate what platform and Java VM version were used to create the jar. Here are the two different entries, from MacOS X and Windows, respectively. Apple: Created-By: 1.4.2-54 ("Apple Computer, Inc.") Ant-Version: Apache Ant 1.6.5
Sun: Created-By: 1.4.2_09-b05 (Sun Microsystems Inc.) Ant-Version: Apache Ant 1.6.5
The primary difference between the two is the java.vm.vendor string in the Apple-created jar is quoted. While all of Sun’s documentation assures us this is legal (they do it themselves in their documentation, but not in their runtime). Removing the quotes from the manifest corrected the problem. Note that this problem only surfaces when using Apache Ant. The jar tool that Apple includes with MacOS X actually produces manifest files that do not have quotes.
Workaround: In your Ant build file, add this as a sub element of your jar or zipfile task: