How to rename a class and its corresponding file in Eclipse

cannot find any menu item for this. Is this doable?

+70
java eclipse
Mar 03 '11 at 8:45
source share
10 answers

Just right-click on the class in the project explorer and select "Refactor-> Rename". That it is under the "Refactor" submenu.

+138
Mar 03 2018-11-11T00:
source share

Shift + alt + r (Right Click File โ†’ refactor โ†’ rename) when the cursor is in the class name. File and constructors will also be changed.

+12
Mar 03 '11 at 8:50
source share

Right click on file -> refactor -> rename?

+6
Mar 03 2018-11-11T00:
source share

You can rename classes or any file by pressing F2 on the file name in Eclipse. He will ask you if you want to update the links. It's really that simple:)

+5
Oct 12 '13 at 20:26
source share

Just rename the class to source code. Eclipse will indicate an error by underlining the class name with red squiggly. Hover over this line with your mouse and eclipse to enable you rename compilation unit . Click on it.

+3
Dec 18 '12 at 6:32
source share

Just select a class, right-click and select rename (maybe F2 too). You can also select the class name in the source file, right-click, select Source, Refactor and rename. In both cases, both the class and the file name will be changed.

+1
Mar 03 2018-11-11T00:
source share

Click on the class and press Alt + Shift + R , after which you can change it to the desired name, and the name of the corresponding file will also be changed.

0
Apr 28 '18 at 14:20
source share

None of this works for me ... I do not find "Refactor-> Rename" in the file context menu, and the key codes also do not work ...

0
Feb 03 '19 at 18:09
source share

Right click on class-> select Refactor-> Rename

0
Mar 08 '19 at 5:57
source share

I found that the above answers did not give me the necessary guidance (I also expected that I would be in the code for the .java file, I will right-click on the tab and see the Refactor option). Here is what I did:

  1. Go to the top of the .java module (ctrl + Home)
  2. Double-click the class name that matches the name of the .java module, and the class name should now be highlighted.
  3. Right-click on the highlighted class name | An open type hierarchy. A type hierarchy should open showing the class name
  4. Right-click the class name in the Type Hierarchy | Refactoring | Rename | enter a new name in the Rename Type popup
0
Jul 11 '19 at 1:27
source share



All Articles