Setting the order of import statements
-
From the menu bar, select Window > Preferences.
-
In the left pane, expand the Java > Code Style category and select Organize Imports.
-
The Organize Imports page defines the sorting order of import statements.
In the Imports list, manage the list of package prefixes as follows:
-
New to add a new prefix
-
New Static to add a new prefix for static imports (J2SE 5.0 only)
-
Edit to change the name of an existing prefix
-
Use Up and Down buttons to rearrange the sequence
of the list by moving the selected prefix up or down
-
Remove to remove the selected prefix from the list
-
Use Import... and Export... to load a list of prefixes from a file
or to store it to a file
-
In the Number of imports needed before .* field,
type the number of import statements that are allowed to refer to the
same package before <package prefix>.* is used.
This number is called the import threshold.
-
Click OK when you are done.
Note: The order of import statements can also be configured per project:
-
Select a java project, open the pop-up menu and choose Properties.
-
Select the Code Style > Organize Imports page and check Enable project specific sttings.
-
Manage the list as explained above.
-
Click OK when you are done.
Java editor
Adding required import statements
Managing import statements
Organizing existing import statements
Refactoring actions
Organize Import preference page