Reputation: 351
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.
Upvotes: 6
Views: 35098
Reputation: 963
I managed to make this work about 90% in macOS Beyond Compare v4.4.7. Thanks to @Codizon for great guidance.
File Formats...
in the context menu+
to create a new file format for .class extension*.class
in General tabExternal program
{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.
Upvotes: 0
Reputation: 29
The link to more formats is old in the above answer. Here use this one.
https://www.scootersoftware.com/kb/moreformats
Download Java Class to Source file format from https://www.scootersoftware.com/kb/moreformats
In Beyond Compare, pick Tools | Import Settings.
Fill in the downloaded filename, and click Next and proceed to finish.
Upvotes: 0
Reputation: 447
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.
Upvotes: 3
Reputation: 1334
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.
Upvotes: 0
Reputation: 2971
Download Java Class to Source file format from http://www.scootersoftware.com/download.php?zz=kb_moreformatsv4
In Beyond Compare, pick Tools | Import Settings.
Fill in the downloaded filename, and click Next and proceed to finish.
Upvotes: 4
Reputation: 2899
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.
Upvotes: 12