Renaming a compilation unit

To rename a compilation unit:

  1. In the Package Explorer, select the compilation unit you want to rename.

  2. From the view's pop-up menu, select Refactor > Rename.

Renaming a compilation unit also renames (and updates all references to) the top-level type that has the same name as the compilation unit. For example, renaming a compilation unit A.java in which a class A is declared also renames class A and updates all references to it.

Related concepts

Refactoring support

Related tasks

Copying and moving Java elements
Viewing compilation errors and warnings
Creating a class in an existing compilation unit
Creating a new interface in a compilation unit
Showing a type's compilation unit in the Packages view

Related reference

Package Explorer
Refactoring actions
Refactoring dialogs
Refactoring preferences

Legal notices