Creates an import declaration for a type reference currently selected. If the type reference if qualified, the qualification will be removed if possible. If the referenced type name can not be mapped uniquely to a type of the current project you will be prompted to specify the correct type. Add Import tries to follow the import order as specified in the Organize Import preference page.
Adding required import statements
The Java editor can help you adding required import statements for a selected type inside a compilation unit.
Select a reference to a type in your Java code, and do one of the following:
Select Source > Add Import from the pop-up menu in the editor
Select Source > Add Import from the menu bar.
Press Ctrl + Shift + M
Either the editor can identify the type or you are prompted to choose the desired type from a list of possible types.
The import statement is generated and inserted as specified by the import order preference.
Organizes the import declarations in the compilation unit currently open or selected. Unnecessary import declarations are removed, and required import declarations are ordered as specified in the Organize Import preference page (Window > Preferences > Java > Code Style > Organize Imports). Organize import can be executed on incomplete source and will prompt you when a referenced type name can not be mapped uniquely to a type in the current project.
You can also organize multiple compilation units by invoking the action on a package or selecting a set of compilation units.
Organizing existing import statements
The Java editor can help you improve the existing import statements inside a compilation unit.
Do one of the following while editing your Java code:
Select Source > Organize Imports from the pop-up menu in the editor
Select Source > Organize Imports from the menu bar
Press Ctrl + Shift + O
The Java editor generates a complete list of import statements, as specified by the import order preference, and new import statements replace the old ones.