Code style
NOTE: This assumes you’re using the most recent version of Eclipse. Older versions have slightly different user interfaces.
In Eclipse, select Preferences in the Window menu.
In the navigation pane on the left side of the Preferences dialog, drill down to Java > Code Style > Formatter.
Click Edit....
In the Indentation submenu, set the Tab policy to Spaces only. Underneath that, set both the Indentatation size and Tab size to 2.
In the New lines submenu, in the In control statements subsection, select all four checkboxes that start with "Before".
In the Line wrapping submenu, set the Maximum line width to 100.
In the Profile name textbox at the top of the dialog, rename the profile to whatever you prefer and click OK.
Back in the main Preferences dialog, make sure the active profile is set to the one you just named and click Apply.
Still in the main Preferences dialog, in the navigation pane on the left side, drill down to General > Editors > Text Editors, and check "Show line numbers" if it isn’t already.
Select OK to close the dialog.