> Dan.
> >>> I just upgraded my development environment (on Windows/2000) to
> >>> use J2SE 1.5.0_07, and even though I recreate the application Jar
> >>> file from scratch, and I attempt to run it using java -jar, I
> >>> get Invalid or corrupt jarfile.
Had this problem myself. Does: 'java -cp my.zip my.main.class' work as
expected?
> >>> I did a search for this message and found only one posting which seemed
> >>> to provide a solution, in which it said that the META-INF/MANIFEST.MF
[quoted text clipped - 13 lines]
> > Which zip utility are you using? Some of them do unnatural things with
> > line endings in text files, which could be messing with your manifest.
A zip is a jar is a zip. By definition, a zip utility will not alter
("mess with") any files. That is, the output will be the same as the
input unless you use some modifiers (unix to win line ending conversion
etc.).
> Info-Zip, version 2.3 on Windows/2000.
>
[quoted text clipped - 15 lines]
> using a file list, where Jar doesn't support that (at least, not that
> I can find).
Use Ant (http://ant.apache.org/). Specifically the 'jar' task.
> Note that this all works when I use J2SE 1.4.2_06 (the version I was
> using before upgrading to 1.5.0).
When this happened to me, I found that the default java.exe that was
running was not the new one, but the one in c:\windows\system32\. I
set the environment variables so so that PATH contains the java 1.5 bin
path before all others and setting JAVA_HOME to the correct java 1.5
path worked.
At the time, I thought it was odd that the message stated that the jar
was corrupt when running java -cp my.zip my.class.path worked fine.
Kind of misleading.
Hope this helps,
--Russ
> Thanks,
>
> > Dan.
Mark Hansen - 17 Jul 2006 16:48 GMT
>> >>> I just upgraded my development environment (on Windows/2000) to
>> >>> use J2SE 1.5.0_07, and even though I recreate the application Jar
[quoted text clipped - 3 lines]
> Had this problem myself. Does: 'java -cp my.zip my.main.class' work as
> expected?
Yes, but it's doing a different thing. What I'm trying to use is the
java -jar feature.
>> >>> I did a search for this message and found only one posting which seemed
>> >>> to provide a solution, in which it said that the META-INF/MANIFEST.MF
[quoted text clipped - 39 lines]
>> I can find).
> Use Ant (http://ant.apache.org/). Specifically the 'jar' task.
Thanks. I know there are other ways to create the jar file, but as I
said, I'm using Zip, and my question was about how to make that work.
>> Note that this all works when I use J2SE 1.4.2_06 (the version I was
>> using before upgrading to 1.5.0).
[quoted text clipped - 8 lines]
> was corrupt when running java -cp my.zip my.class.path worked fine.
> Kind of misleading.
Misleading? It seems the problem is in how the MANIFEST.MF file is placed
in the archive. Not using the -jar option seems like it would bypass this
logic, and so not run into the problem.
Now, from my experimentation, if the manifest file is placed in the archive
by Zip, then java -jar chokes. If its added by the 'jar' command (regardless
of how the archive is created), then java -jar is happy.
However, in looking at the MANIFEST.MF entry in the archive for both cases,
I can't see any different in the file. Perhaps the problem is in the TOC
entry created for the file? Not sure. Adding the file using the Jar command
seems to work around the problem.
Thanks,