• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Manifest problem in creating a jar file (CLI)  RSS feed

 
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 21502
96
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And don't forget that class names never end with ".class".
 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!