Accepted answer

just right click on the class in the project explorer and select "refactor" -> "rename". that it is is under the "refactor" submenu.


click on the class and press the alt + shift + r keys, then you can change it to the required name and the corresponding file name will also be changed.


right click on the class->select refactor->rename


i found the answers above didn't give me the guidance i needed (i too expected to be in the code for the .java file, and right-click on the tab and see a refactor option). here's what i did:

  1. go to the top of the .java module (ctrl+home)
  2. double-click on the class name that is the same name as the .java module and the class name should now be highlight
  3. right-click the highlighted class name | open type hierarchy. the type hierarchy should open showing the class name
  4. right-click the class name in the type hierarchy | refactor | rename | type the new name in the popup window rename type


to rename file using refactoring (which also updates all occurrences of name in other scripts):

  1. save changes to file before using refactoring/renaming
  2. in project explorer view, right-click file to be renamed and select refactor | rename -or- select it and go to refactor | rename from the menu bar. a rename file dialog will appear.
  3. enter the file's new name.
  4. check the "update references" box and click preview.
  5. you can scroll through changes using the select next / previous change scrolling arrows.
  6. press ok to rename file and update all occurrences of the script name in other scripts.

see "php developer user guide > tasks > using refactoring > renaming files".


simply select the class, right click and choose rename (probably f2 will also do). you can also select the class name in the source file, right click, choose source, refactor and rename. in both cases, both the class and the filename will be changed.


just rename the class in the source code. eclipse will point out an error by underlining the class name with a red squiggly line. hover on that line with your mouse pointer and eclipse will give you the option to rename compilation unit. click on that.


you can rename classes or any file by hitting f2 on the filename in eclipse. it will ask you if you want to update references. it's really as easy as that :)


right click file -> refactor -> rename.


shift + alt + r (right click file -> refactor -> rename) when cursor is on class name. the file and constructors will be also changed.

Related Query

More Query from same tag