FAQ
Most frequent questions
- What is 3-way merge?
- Can I use JDiff without UI?
- What is Myers algorithm?
- Can it detect moved blocks?
- Can I integrate JDiff in my own project?
- What is 3-way merge?
- Merging two versions of the same file can be quite tricky. The most difficult task is to detect conflicts, and the best way to achieve this is to use the "common ancestor" from which the two versions are issued: merge is done using actually 3 files, this is the 3-way merge. This allows determining which portion of the file has been modified for each, and deduce simply where conflicts are occuring. Then, for all the other modified portions, the algorithm performs an automatic merge.
- Can I use JDiff without UI?
- Yes, both diff and merge engines can be used without JDiff graphical interface. For instance, retrieving the merge result of 2 strings can be done using: MergeResult mergeResult = Diff.quickMerge(commonAncestor, version1, version2); The "mergeResult" object will contain a list of items that allows building the merged file.
- What is Myers algorithm?
- Myers wrote an algorithm that performs the minimum set of differences between 2 arrays of objects. It can be used to compare files, but it can actually be used to compare any kind of arrays. Within JDiff, files are decomposed as arrays of lines, which implies that a few character modified within a given line will end up with the whole line considered as different.
- Can it detect moved blocks?
- No, a moved block will be considered as deleted on one side and added on the other. This could be a future enhancement.
- Can I integrate JDiff in my own project?
- Yes, JDiff is released using the LGPL licence agreements, which means you can use it for free, even in commercial products, without the need to publish your own sources. However, you must keep a clear status within your project, stating that you are using an external LGPL library. Moreover, if you bring any change to the library, you must publish them.

Contact us