You can open the Import Management Tool (IMT) by right-clicking a file in the
Filesystems window or Source Editor and choosing Tools Import
Management Tool. The Remove Unused Imports page 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 actions:
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 page displays only a message and no actions are possible.
By default, the IMT replaces all fully qualified names with import statements
and simple names. You can configure the IMT to only create an import statement
for a class when the class appears a certain number of times in the file. For
example, you can choose to leave fully qualified names for classes that only
appear one or two times, but create import statements for all classes that appear
three or more time. To set the IMT threshold, choose Tools Options
from the main window, expand Editing
Java
Sources, and select Import Management Settings. Then enter the maximum occurrences
of fully qualified names in the Fully Qualified Name Threshold property.
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 Wildcard Import Statement Strategy property in the Import Management Tool Settings.