Comparing two .jar files

前端 未结 11 1381
灰色年华
灰色年华 2020-12-04 06:57

How do I compare two .jar files? Both of them have compiled .class files.

I want the difference in terms of method changes, etc.

相关标签:
11条回答
  • 2020-12-04 07:06

    In Linux/CygWin a handy script I use at times is:

    #Extract the jar (war or ear)
    cd dir1
    jar xvf jar-file1
    for i in `ls *.class`
    do
     javap $i > ${i}.txt #list the functions/variables etc
    done
    
    cd dir2
    jar xvf jar-file2
    for i in `ls *.class`
    do
     javap $i > ${i}.txt #list the functions/variables etc
    done
    
    diff -r dir1 dir2 #diff recursively
    
    0 讨论(0)
  • 2020-12-04 07:11
    1. Rename .jar to .zip
    2. Extract
    3. Decompile class files with jad
    4. Recursive diff
    0 讨论(0)
  • 2020-12-04 07:12

    If you select two files in IntellijIdea and press Ctrl + Dthen it will show you the diff. I use Ultimate and don't know if it will work with Community edition.

    0 讨论(0)
  • 2020-12-04 07:13

    I use to ZipDiff lib (have both Java and ant API).

    0 讨论(0)
  • 2020-12-04 07:14

    Use Java Decompiler to turn the jar file into source code file, and then use WinMerge to perform comparison.

    You should consult the copyright holder of the source code, to see whether it is OK to do so.

    0 讨论(0)
  • 2020-12-04 07:15
    • JAPICC, sample usage:

      japi-compliance-checker OLD.jar NEW.jar

      Sample reports for log4j: http://abi-laboratory.pro/java/tracker/timeline/log4j/

    • PkgDiff, sample usage:

      pkgdiff OLD.jar NEW.jar

      See sample report for args4j.

    • Clirr, sample usage:

      java -jar clirr-core-0.6-uber.jar -o OLD.jar -n NEW.jar

    0 讨论(0)
提交回复
热议问题