How do I compare two files using Eclipse? Is there any option provided by Eclipse?

Eclipse

Eclipse Problem Overview


How do I compare two files using Eclipse?

(Currently I am using WinMerge.)

Eclipse Solutions


Solution 1 - Eclipse

To compare two files in Eclipse, first select them in the Project Explorer / Package Explorer / Navigator with control-click. Now right-click on one of the files, and the following context menu will appear. Select Compare With / Each Other.

enter image description here

Solution 2 - Eclipse

Just select all of the files you want to compare, then open the context menu (Right-Click on the file) and choose Compare With, Then select each other..

Solution 3 - Eclipse

If one or both of the files you wish to compare isn't in an Eclipse project:

  1. Open the Quick Access search box
  • Linux/Windows: Ctrl+3
  • Mac: ⌘+3
  1. Type compare and select Compare With Other Resource

  2. Select the files to compare → OK

You can also create a keyboard shortcut for Compare With Other Resource by going to WindowPreferencesGeneralKeys

Solution 4 - Eclipse

Other than using the Navigator/Proj Explorer and choosing files and doing 'Compare With'->'Each other'... I prefer opening both files in Eclipse and using 'Compare With'->'Opened Editor'->(pick the opened tab)... You can get this feature via the AnyEdit eclipse plugin located here (you can use Install Software via Eclipse->Help->Install New Software screen): http://andrei.gmxhome.de/eclipse/

Solution 5 - Eclipse

If your compairing javascript you might find it not displaying.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=509820

Here is a workround...

> * Window > Preferences > Compare/Patch > General Tab > * Deselect checkbox next to "Open structure compare automatically"

Solution 6 - Eclipse

Compare with Other Resource – The Easy Way using Eclipse (no additional plugin required)

To assign a keyboard shortcut to the feature, go to Window > Preferences > General > Keys, look for the command Compare with Other Resource and assign it to a keyboard shortcut of your liking. See How to manage keyboard shortcuts in Eclipse for more details on configuring shortcuts.

Tip: Alternatively, you could press Ctrl+3 (for Quick Access) and search for Compare with Other Resource. This way you don’t have to configure a shortcut but you’ll have to search for the command every time in Quick Access.

Once the shortcut is assigned, you need to select the source file from the Package Explorer, Project Explorer or Navigator. The easiest way to do this from an open editor is to assign a shortcut to instantly show the file in the Package Explorer or, if it’s not open, to open it quickly using the keyboard.

Select_File_In_Package_Explorer

Now press the keyboard shortcut you assigned to Compare with Other Resource and the following (non-modal) dialog should appear:

Compare With Each Other Dialog

Troubleshooting: If the dialog doesn’t appear, it’s probably because you haven’t selected a file in either the Package Explorer or another view that allows file selection. Make sure a file is selected and make sure you haven’t selected the class in the Package Explorer rather than the actual Java file.

Now you can select the second file in the Package Explorer and drag and drop it onto the dialog. Click OK and the comparison editor should display, comparing the two selected files.

Comparison Editor

Tip: See the post on using shortcuts for common SVN commands for tips on how to navigate the comparison editor with the keyboard.

Comparing External Files Using the Compare with Other Resource dialog, you can compare a workspace file with an external file or even compare two external files with each other.

Comparing a workspace file with an external file is easy: Once you’ve opened the dialog from a selected file, instead of dragging and dropping another workspace file, tick External File in the Right pane and then Browse to a file on your filesystem.

comparing external

To compare two external files, you have to start the dialog again from a selected workspace file (choose an arbitrary file). Once open, select External File in the Left pane and Browse to your file then do the same for the Right pane.

Please refer this page for more details: http://www.eclipseonetips.com/2013/09/19/compare-two-workspace-or-external-files-in-eclipse/

Solution 7 - Eclipse

If you have Beyond Compare installed, the ContextQuickie eclipse plugin has an option to enable it to be selected from the context menu displayed when you right-click a file.

Install from:

https://github.com/ContextQuickie/ContextQuickie/wiki/Installation

After install, activate Beyond Compare menu items via Window->Preferences->Context Quickie->check 'Enable Beyond Compare'.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRPBView Question on Stackoverflow
Solution 1 - EclipseVikas PatidarView Answer on Stackoverflow
Solution 2 - EclipseDoonView Answer on Stackoverflow
Solution 3 - EclipsebmaupinView Answer on Stackoverflow
Solution 4 - Eclipsearmyofda12mnkeysView Answer on Stackoverflow
Solution 5 - Eclipseandrew pateView Answer on Stackoverflow
Solution 6 - EclipseBarani rView Answer on Stackoverflow
Solution 7 - EclipserandyjView Answer on Stackoverflow