Compare files .class Beyond Compare 4
Asked Answered
S

6

6

I'm using Beyond Compare 4 (4.1.9) in order to compare war files.

I need to compare the files .class that I find in the several packages.

  1. How I can compare them using this product (Beyond Compare 4)?
  2. Otherwise there is another product which can compare war file and compile the .class files?
Soggy answered 6/12, 2016 at 8:52 Comment(0)
M
12

Double clicking on a war file in Beyond Compare's folder compare will expand it as a folder because war files are essentially zip files.

To decompile Java class files to source code in Beyond Compare, install the Java Class to Source file format. With the file format installed, when you double click on a .class file inside a .war archive, it will display the decompiled source code in Beyond Compare's Text Compare.

Download page for file formats: http://www.scootersoftware.com/download.php?zz=kb_moreformatsv4

Note the Java class to source file format is only available for Windows, it isn't available for the Linux or Mac versions of Beyond Compare.

Mute answered 7/12, 2016 at 21:31 Comment(0)
E
4
  1. Download Java Class to Source file format from http://www.scootersoftware.com/download.php?zz=kb_moreformatsv4

  2. In Beyond Compare, pick Tools | Import Settings.

  3. Fill in the downloaded filename, and click Next and proceed to finish.

Euromarket answered 25/9, 2019 at 11:56 Comment(0)
P
3

Option : javap -l -p -c -constants %s > %t 2>&1 : doesn't work for me on beyondCompare4 4.3.7 (latest version to this date), and if used directly through cmd, gives a .class output but the formatting is bad and it is not really interpretable for the java reader I am.

Option to download the format through http://www.scootersoftware.com/download.php?zz=kb_moreformatsv4 : doesn't work for me neither. This library is based http://varaneckas.com/jad which is quite old.

The option I recommend and that worked is : Download https://github.com/kwart/jd-cli (project based from the famous "Java Decompiler" or "jd-gui" as we know it). Once it is installed, do the following in BeyondCompare4 : Go in format, create a new format, use external program, and use the following : C:\Users%USERNAME%\jd-cli-1.2.0-dist\jd-cli.bat %s > %t 2>&1

Hope this will help some.

Politico answered 16/6, 2021 at 16:37 Comment(0)
B
0

I recently came across the need to compare class files in Beyond Compare 4 and so I found that adding an external program and using javap -l -p -c -constants %s > %t 2>&1 was enough for me. Just make sure a reasonably recent javap is one the PATH that understands any of the class file formats you'd want to compare. No extra software required and is cross platform compatible.

Blob answered 20/6, 2020 at 1:49 Comment(0)
B
0

The link to more formats is old in the above answer. Here use this one.

https://www.scootersoftware.com/kb/moreformats

  1. Download Java Class to Source file format from https://www.scootersoftware.com/kb/moreformats

  2. In Beyond Compare, pick Tools | Import Settings.

  3. Fill in the downloaded filename, and click Next and proceed to finish.

Briton answered 18/3 at 10:18 Comment(0)
B
0

I managed to make this work about 90% in macOS Beyond Compare v4.4.7. Thanks to @Codizon for great guidance.

  1. Install jd-cli(https://github.com/intoolswetrust/jd-cli) : this is a maven project. mvn install will generate jd-cli.jar
  2. Run Beyond Compare then select File Formats... in the context menu
  3. Click + to create a new file format for .class extension
  4. Put value of Mask *.class in General tab
  5. Go to Conversion tab, select External program
  6. Enter Loading like this : {java path} -jar {jd-cli.jar path} %s -g ERROR > %t

e.g. my actual command was like this.

/opt/homebrew/Cellar/openjdk/20.0.1/libexec/openjdk.jdk/Contents/Home/bin/java -jar /Users/myMac/Documents/source_codes/jd-cli-jd-cli-1.2.1/jd-cli/target/jd-cli.jar %s -oc -g ERROR > %t

The only thing bothers me is that it changes package value by putting absolute path prior to it's original value which results the whole class files marked as different in Folder Compare view.

Braden answered 17/6 at 10:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.