Getting WinMerge to compare .jar files

Tomas Aschan picture Tomas Aschan · Jun 10, 2013 · Viewed 9.1k times · Source

I have two directories which contain a handful of *.jar and *.war archives, as well as some metadata files and a file with *.spring extension, which is really just a zip file with an odd name. Something like this:

- dist1
    - a subfolder
        - some text file.txt
    - application-context.xml
    - arch1.jar
    - arch2.jar
    - arch3.jar
    - super-cool.war
    - xtremely-awesome.spring
- dist2
    - a subfolder
        - some text file.txt
    - application-context.xml
    - arch1.jar
    - arch2.jar
    - arch3.jar
    - super-cool.war
    - xtremely-awesome.spring

I'd like to do directory comparison on these directories, comparing the archives as if they were subfolders rather than binary files. Other files, both text and binary files both outside and inside the archives, should be compared as usual.

I know I could just explode all the archives manually and compare the exploded versions, but since they are generated by a build script and exploding them adds a considerable amount of time for building the project, it would be nicer to just do it for the comparison, preferrably within the diff tool.

I've tried using WinMerge with the 7zip plugin, but I can't get the plugin to work (the files are not recognized as archives in the folder compare view). I've tried both installing as a "shared installation" and as an "application specific installation" (pointing the installer to C:\Programs\WinMerge\WinMergeU.exe). I've also tried manually copying the .dll files from the plugin into the MergePlugins folder, without success.

How do I get this working in WinMerge? And if it's not possible, is there some other good tool that has this capability?

Answer

Palec picture Palec · Sep 12, 2015

Since WinMerge 2.15.2 (2018-01-28), archives are supported out of the box. See the change log section "Archive support" for changes to the functionality.

For the 2.15.2 release, the changelog says:

Archive support

  • Install 7-zip plugin by default

Options dialog

  • ...
  • Remove "Use stand-alone 7-Zip if available" and "Use local 7-Zip from WinMerge folder" radio button from "Archive Support" page (Now always use local 7-Zip from WinMerge folder)
  • ...

In WinMerge 2.14.01, the easiest way to enable archive support is to

  • download the 7-Zip plugin for WinMerge2,
  • use its installer to install the DLLs and related components for the latest 7-Zip supported into the folder of WinMerge3 (select the “Application specific installation” and “Enable standalone operation”), and
  • change the WinMerge settings to use these files and detect archive type automatically (in “Options → Archive Support” select “Enable archive file support”, “Use local 7-Zip from WinMerge folder” and “Detect archive type from file signature”).

Plugin installer with correct final settings screenshot
Image and the solution are by jtuc, the developer of WinMerge. I found them in a WinMerge forum thread.

Then, if you compare two JAR files (or files in any other archive-based format, e.g. ODF or OOXML), their contents should be compared as if they were extracted first. It works for me on Windows 10.

Some details on installing archive support are mentioned in the WinMerge manual.

1 WinMerge 2.14.0 is the latest stable release as of 2017-06, released on 2013-02-03.
2 Merge7z DllBuild 0028 is the latest as of 2015-09, released at 2010-12-28.
3 The DLLs are Merge7z920.dll and Merge7z920U.dll for 7-Zip 9.20 in Merge7z DllBuild 0028, and the path to WinMerge executable is probably C:\Program Files (x86)\WinMerge\WinMergeU.exe. The “U” stands for Unicode in both the DLL’s and executable’s name. For WinMergeU.exe, only Merge7z920U.dll is needed, but better have both and don’t have to care.