简体   繁体   中英

Why do these two jar files with identical contents have different file sizes?

I am reorganizing our java code base and wanted to compare our resultant jar files.

When I build in the old source tree, I get a jar file size of 3360081.

In the new source tree it is 3360128.

I do a "jar tvf jarfile" and then strip the dates out of the file.

The listing looks like this:

     0 Mon Mar 16 10:41:16 EDT 2009 META-INF/
   102 Mon Mar 16 10:41:14 EDT 2009 META-INF/MANIFEST.MF
     0 Mon Mar 16 10:41:14 EDT 2009 decodes/

After I strip the dates, the listing looks like this:

     0  META-INF/
   102  META-INF/MANIFEST.MF
     0  decodes/

The two jar listings are identical.

What would cause a 47 byte difference in "identical" jar files?

I am running the compile on RedHat Linux 4.

File modification times of the compiled files are most probably the reason. Also, your class files might actually be different. If you reorganized your package structure they most definitely will.

It's probably not the case - but by any chance are you using different compiler versions (even minor version differences) while compiling the two source bases?

If you use BeyondCompare (or similar) it will diff your jar files and identify the different files within the archives (down to the line/character differences for a text file, or just highlight the binary files that have changed).

(I don't think file modification times are stored in their text representation in the.jar format, and I don't believe they'll contribute to.jar file sizes)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM