Actually runnin the version 2 code im gettin into some problems (the previous stages work fine)...
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)
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.