Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / July 2006

Tip: Looking for answers? Try searching our database.

J2SE 1.5.0_07: Invalid or corrupt jarfile

Thread view: 
Mark Hansen - 07 Jul 2006 18:29 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
file from scratch, and I attempt to run it using java -jar, I
get Invalid or corrupt jarfile.

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
file must be specified using all upper-case characters, but mine already
is.

I also looked through the online Jar file guide for information on the
format of the MANIFEST.MF file, and mine appears to be correct.

Note that even if I remove the manifest.mf file, I get the same error
when attempting to run the Jar file.

I am creating the Jar file using the 'zip' utility, and even added the
-0 (zero) arg to remove any compression of the archived files, but this
didn't help.

If I create the Jar using the 'jar' utility, it works.

Is it no longer possible to create the Jars using the 'zip' utility?

Thanks
Mark Hansen - 07 Jul 2006 18:57 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 - 21 lines]
>
> Thanks

I found that I can create the Jar file using the 'zip' utility, as long
as I add the manifest file using the 'jar' utility last, as in:

  zip ... to create the Jar file
  jar -ufm my.jar manifest.txt

Strange, but this is a reasonable work around for my use.

Thanks,

Signature

Mark Hansen, PP-ASEL, Instrument Airplane
Cal Aggie Flying Farmers
Sacramento, CA

Daniel Dyer - 07 Jul 2006 21:57 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 - 14 lines]
>>  Is it no longer possible to create the Jars using the 'zip' utility?
>>  Thanks

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.

> I found that I can create the Jar file using the 'zip' utility, as long
> as I add the manifest file using the 'jar' utility last, as in:
[quoted text clipped - 3 lines]
>
> Strange, but this is a reasonable work around for my use.

Why not just used jar to create the whole thing?

Dan.

Signature

Daniel Dyer
http://www.dandyer.co.uk

Mark Hansen - 07 Jul 2006 22:05 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 - 17 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.

Info-Zip, version 2.3 on Windows/2000.

The line endings shouldn't matter, according to the documentation
for the manifest file. It claims that they can end in a variety of
ways and be legal (of course, that doesn't preclude a bug...).

>> I found that I can create the Jar file using the 'zip' utility, as long
>> as I add the manifest file using the 'jar' utility last, as in:
[quoted text clipped - 5 lines]
>
> Why not just used jar to create the whole thing?

For my build environment, Zip is easier. I can create the archive
using a file list, where Jar doesn't support that (at least, not that
I can find).

Note that this all works when I use J2SE 1.4.2_06 (the version I was
using before upgrading to 1.5.0).

Thanks,

> Dan.
russ.sherk@gmail.com - 17 Jul 2006 16:02 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
> >>> 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,


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.