Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help in runnin sample code version 2 in mehran habibis book

 
Abhi Chat
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually runnin the version 2 code im gettin into some problems (the previous stages work fine)...

After ido

jar -cfm sampleproject.jar Manifest.MF -C classes

I get errors like

java ioexception: invalid header field
at java.util.jar.Attributes.read(Attributes.java:387)
at java.util.jar.Manifest.read(Manifest.java:167)
at java.util.jar.Manifest<init>(Manifest.java:52)
at java.util.jar.Main.run(Main.java:124)
at java.util.jar.Main.main(Main.java:904)

please advice
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A wild guess: the jar command documentation says that it's "jar cmf" not "jar cfm". So are the filenames being taken in the wrong order?
 
Abhi Chat
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i tried both options didint work...so i typed the option "cfm" as in the book (page 324)...

Ya all the class files are present and they have been arranged in the folder
classes/db/*.class
/remote/
/test/
/gui/

the Manifest.MF file calls the class: sampleproject.gui.ApplicationRunner..

Still I get those errors...
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Abhi,

You have missed a fullstop (or period) on your posted command line. That is, you have:



Whereas Max's command line is:



Notice that space and fullstop that appears after the "classes"? It is important.

I suspect that this is just a typo when you pasted your command line into this topic. What appears more likely is that your manifest itself is missing or invalid. Looking at the error message you posted:



The error appears to be occuring while the jar command is attempting to read the manifest (the 3rd line tells us that this is during Manifest.read, and the second line tells us that it is trying to read an attribute from the manifest).

The jar application is expecting to find the manifest file in the directory where you are running the jar application (note that you have specified the manifest before the "-C" option which changes the directory for finding the class files to include. If you look at Max's example you can see that he does have a Manifest.mf in that directory.

Do you have this file? Does it contain the same information as described on page 321?

If it does, and you are still getting errors, try adding an extra blank line to the end of your manifest file. Some versions of the jar program seem to require a blank line after the last command - some dont.

One final note about order of command line arguments - they must match the order of your command line switches. You are fine with the way you are trying to do it, but since you mentioned that you tried the commands both ways, I thought I'd mention this.

So the command: has the options f follwed by m, so you must list the filename to create first, followed by the manifest to use.

Wheras the command: has the options m follwed by f, so you must list the manifest to use first, followed by the filename to create.

Clear as mud?

Regards, Andrew
 
Abhi Chat
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Andrew ....adding that blank line worked......

Regards

Abhi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic