Small edits can leave a Java file with uneven indentation and spacing. The Eclipse IDE on the Linux desktop can format the code throughout the file using a single set of rules.
The active Java formatter profile determines where braces go, how far statements indent, and when long lines wrap. A project with its own formatter settings can lay out the same code differently from the workspace default.
The editor selection controls how much code Eclipse formats. With no selection, Eclipse applies the profile to the entire file, including lines outside your latest edits.
Steps to format code in Eclipse:
Start with a saved .java file open in the Java editor, a visibly misaligned method body, and no text selected. The screenshots show sample/src/reports/Report.java in ~/eclipse-workspace.
If Eclipse shows the Install Java 27 Support notice at startup, you can choose whether to install it. Continue at step 1 once your Java file is open in the editor.
- Open the Source menu in the Eclipse menu bar.

- Choose Format from the Source menu.

- Click Save on the toolbar.

- Confirm that each previously misaligned statement has moved from where it was in step 1 and that the editor tab shows no unsaved dot.
With the default profile in the example,
System.out.println(2 + 3);moves to one level insidemaininReport.java.