Moving a compilation unit

You can move a compilation unit to a different package. Imports and references are automatically updated.

To move a selected compilation unit and update all references to it:

  1. In the Package Explorer, select a compilation unit.
  2. From the compilation unit's pop-up menu, select Move to Another Package. The Move Compilation Unit to Another Package page opens.
  3. In the Choose package to move the compilation unit to field, type or click Browse to select the name of the package where you want the compilation unit to move.
  4. Click Next to perform a refactoring without preview, or click Finish to perform a refactoring with preview.

Related concepts

Refactoring support

Related tasks

Refactoring without preview
Refactoring with preview
Renaming a compilation unit
Moving folders, packages, and files
Copying and moving Java elements

Related reference

Package Explorer
Refactoring actions