This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Manifest problem in creating a jar file (CLI) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Manifest problem in creating a jar file (CLI)" Watch "Manifest problem in creating a jar file (CLI)" New topic
Author

Manifest problem in creating a jar file (CLI)

Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 659

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)

>


Jon
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12921
    
    3

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

And don't forget that class names never end with ".class".


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Jon Camilleri
Ranch Hand

Joined: Apr 25, 2008
Posts: 659

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
Bartender

Joined: Aug 16, 2005
Posts: 12921
    
    3

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Manifest problem in creating a jar file (CLI)
 
Similar Threads
Manifest - JAR file - Exception
Error in running Jar File.
Problem when make .jar file from my java applet program!!!
Executing my .java in package
jar problem