tags:

views:

356

answers:

3

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.

+6  A: 

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.

Bombe
The file modification times are stripped out of the jar listing. There is only filesize and classnames.
Mel
Who cares about the listing? The modification times are stored inside the JAR file. They obviously change when you recompile your code and create a new JAR file.
Bombe
Agree, the times are stored and compressed, so the JAR size changes.
ReneS
+1  A: 

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?

talonx
+1  A: 

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)

Brian Agnew