You can open the Import Management Tool (IMT) by right-clicking a file in
the Explorer or Source Editor and choosing Tools Import
Management Tool. The Remove Unused Imports pane displays all of your source
file's identifiers as an import tree of package nodes and class name subnodes.
![]() |
The java.lang package and the package of your processed class are omitted from the Imports tree view, as these packages are always included by default. |
For package nodes, you can choose the following commands:
You can specify actions on class name subnodes in the following ways:
If there are no import statements to be removed and no import statements to change from package to single-name or the reverse, the Remove Unused Imports pane displays only a message and no actions are possible.
By default, if the source file contains an import statement that is referenced less than five times by a simple name, the IMT removes the import statement and changes the simple names to fully qualified names. You can change the default IMT threshold by changing the Maximum of Fully Qualified Names in Source property in the Import Management Tool Settings.
You can also configure the IMT to choose automatically between package import statements and single-name import statements. By default, if the source file contains more than four single-name import statements for classes from the same package, the IMT's suggested action is Use Package Import. This action removes the single-name import statements and replaces them with a package import statement.
Likewise, if the source code contains less than five simple class names from a single package import statement, the IMT's suggested action is Use Single-Name Import. This actions replaces the package import statement with single-name import statements. You can change the default threshold by changing the Number of Single-Name Imports property in the Import Management Tool Settings.