Mel
Mel

Reputation: 3965

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.

Upvotes: 5

Views: 4908

Answers (3)

Brian Agnew
Brian Agnew

Reputation: 272307

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)

Upvotes: 1

user10996
user10996

Reputation:

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?

Upvotes: 2

Bombe
Bombe

Reputation: 83849

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.

Upvotes: 7

Related Questions