there is a command called jar -tvf <file name>. This command will list all files in jar file alongwith folder structure.
You can probably run this command for both jar files from your java code and than used try comparing output of both of them.
By this you can compare two jar files are same in terms of contents or not. but if you want to check if 2 jar files are having same versions for all files in it than this solution won't work
Chop your own wood, and it will warm you twice. - Henry Ford
You could use the Checksum interface (Alder32, CRC32) classes. You would read the files and pass them to the Checksum. The Checksum will return the same number if the files are the same, however it won't tell you where they are different. You could do all this in a couple lines of code.
Here is an example of this from the always useful Java Almanac:
Why are you even looking at the last 128 bytes of the two files to decide whether the method should return true fo false? I'd think that the method should return true only if the two checksums are identical.
Yes the war files are identical. Please ignore the byte comparison(I was testing some other thing...). The main point is that checksum does not return same long value for identical war files.
Are you sure the files are the same? Remember it just takes just one difference for them to be different. For example the data of a file in the zipfile. Even if the file in the zip file is the same if its date is off the file is off.