This note relates to Eclipse SDK 3.6.2.
When editing a Java source file, in Eclipse, warnings are reported when an import statement is specified but not used. Unused import statements can be removed automatically by using the Java editor menu entry Source > Organize Imports.
This can be automatized when the file is saved using the following approach:
- Open “Preferences” page via menu Window > Preferences
- Navigate to Save Actions for Java Editor (Java > Editor > Save Actions)
- Select Perform the selected actions on save
- Select Organize imports
- Press button Apply
From this point on, when a Java file is saved, import statements will automatically be cleaned.