Eclipse notes

Archived

This page has been archived and will receive no further updates.

Sources:

Java All-In One Desk Reference For Dummies, Second Edition

Misc

Compare files that aren’t in an Eclipse project

  1. Open the Quick Access search box

    • Linux/Windows: Ctrl+3
    • Mac: ⌘+3
  2. Type compare and select Compare With Other Resource

  3. Select the files to compare > OK

Three-way compare

Alternatively, use Meld

  1. Select the first file, then hold down Ctrl and select the other two files

  2. Right-click > Compare With > Each Other

  3. Select the common ancestor (if you’re merging the changes from file a to file b into file c, this is file a)
  4. If the file you want to merge the changes into (file c) is on the left, click the button on the top-right that says “Copy All Non-Conflicting Changes from Right to Left” (and vice-versa if the file you want to merge the changes into is on the right).
  5. Lastly, starting at the top of the page, click the Next Difference button to make sure all of your customizations in file “c” have been preserved, and then click save.

Upgrade Eclipse

  1. Get the update site for the version you want to upgrade to:

    https://wiki.eclipse.org/Eclipse_Project_Update_Sites

  2. Help > Install New Software > Work with > Add > Location > paste the update site you got from the previous step > OK > Cancel

  3. Help > Check for Updates > follow the steps to upgrade Eclipse

Debugging

Step into

Executes the highlighted statement, and then suspends the thread

Step over

Skips the highlighted statement and executes the next statement, and then suspends the thread

Step return/run to return

Executes the highlighted statement and continues executing statements until the end of the current method is reached. Then, the thread is suspended

Tips

  • Position the mouse cursor over a variable in the code pane when debuggin to get that variable’s value

Refactoring

Lets you change all occurrences of the thing you’re refactoring (variable, method)

Refactor > Rename

Refactor > Extract

Lets you create a separate method from one or more statements. select the statement(s) then choose extract

Refactor > Extract local variable

Replaces a repeated expression with a variable