Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Manifest problem in creating a jar file (CLI)

 
Ranch Hand
Posts: 664
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any idea what is wrong with this manifest file please? I'm using WinXP command line. The first line is stated to be the minimum legal manifest by Horstmann and Cornell.



Manifest-Version: 1.0
Name:FileChooserTest.class
Loads a JFileChooser

Command line
>jar cfm FileChooser.jar JFileChooser.mf *.class
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:393)
at java.util.jar.Manifest.read(Manifest.java:182)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.run(Main.java:132)
at sun.tools.jar.Main.main(Main.java:1022)

>
>
>type *.mf

JFileChooser.mf


Manifest-version: 1.0
Name:FileChooserTest.class
Loads a JFileChooser

>jar cfm FileChooser.jar JFileChooser.mf *.class
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:393)
at java.util.jar.Manifest.read(Manifest.java:182)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.run(Main.java:132)
at sun.tools.jar.Main.main(Main.java:1022)

>
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You specify the entry point of the program (the main class) with a Main-Class attribute (not a Name attribute). I'm not sure if Name is a valid attribute in a manifest file.

Also, put a space between the : and the value of the attribute. Make sure that the manifest ends with an empty line; there's a known problem where Java will not read the last line of the manifest file if it doesn't end with an empty line.

See Working with Manifest Files in Oracle's Java Tutorials for details on how to use manifest files.
 
Sheriff
Posts: 22509
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And don't forget that class names never end with ".class".
 
Jon Camilleri
Ranch Hand
Posts: 664
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:You specify the entry point of the program (the main class) with a Main-Class attribute (not a Name attribute). I'm not sure if Name is a valid attribute in a manifest file.

Also, put a space between the : and the value of the attribute. Make sure that the manifest ends with an empty line; there's a known problem where Java will not read the last line of the manifest file if it doesn't end with an empty line.

See Working with Manifest Files in Oracle's Java Tutorials for details on how to use manifest files.



In the meantime I have compiled my first minimalist version of the manifest file with the following command line and manifest file; what tool do I need to create a SHA-5 signature?

Microsoft Windows XP [Version 5.1.2600]
>jar cfm FileChooser.jar JFileChooser.mf *.class
>type JFileChooser.mf
Manifest-Version: 1.0
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess you want to do that because you want to digitally sign your JAR file? The tutorial explains that in detail in this part: Signing and Verifying JAR Files.

Normally it's not required to sign your JAR file. You only need to do that for applets for example, if the applet needs special privileges which go beyond what the normal applet sandbox runtime environment allows applets to do.
reply
    Bookmark Topic Watch Topic
  • New Topic