Renaming a File or Folder

See Also

When you rename a file or folder in your Java project, the file or folder on the hard disk is also renamed.

Important   When renaming an item in your project, you must be careful to manually change all references to the old name. For example, Java requires a public class to have the same name as its source file. Therefore, if you rename a .java file, you must also rename the associated public class, and vice versa.

Note that if you rename a folder, you must change the package statement of each .java file in the folder. If a file's package statement does not map to the folder it resides in, the output directory structure will not match the project directory structure when you build the project.

To rename a file or folder in the project

  1. In Project Explorer, right-click the name of the file or folder to be renamed.

  2. On the shortcut menu, click Rename.

  3. Type the new name and press Enter. This name must be a valid file or package name. For information about valid names, see Identifiers in the Java Language Specification.

Note   If a file or folder is renamed through the file system, it is automatically renamed in Project Explorer. However, you must still change all references to the old name.