Google+

159. Renaming Java Projects, Packages and Classes in Eclipse IDE






In Eclipse, we can rename the Java Projects, Packages and Classes. We have to use 'Refactor -> Rename' option to rename the items in Eclipse IDE.

Lets implement this on Eclipse IDE -

Create a Java Project, a package and a Class in Eclipse IDE, and rename them using 'Refactor' -> 'Rename' option.

1. Launch Eclipse IDE, Create a Java Project 'Project 008' as shown below -


2. Right Click on the Java Project 'Project 008' and select 'Refactor -> Rename' option as shown below -


3. Observe that 'Rename Java Project' dialog is displayed with 'New name' field and change the name from Project 008 to Project 009 and click on 'OK' button as shown below -


4. Observe that the Java Project name got renamed to 'Project 009' under Package explorer as shown below -


5. Create a Package 'package_008' under Renamed Java Project 'Project 009' as shown below -


6. Right Click on the Package 'package_008' and select 'Refactor -> Rename' option as shown below -


7. Observe that 'Rename Package' dialog is displayed with 'New name' field and change the name from 'package_008' to 'package_009' and click on 'OK' button and save as shown below -


8. Observe that the Package name got renamed to 'package_009' under Package explorer as shown below -

9. Create a Class 'Class008' as shown below -


10. Right Click on the Class 'Class008' and select 'Refactor -> Rename' option as shown below -


11. Observe that 'Rename Compilation Unit' dialog is displayed with 'New name' field and change the name from 'Class008' to 'Class009' and click on 'Finish' button and save as shown below -


12. Observe that the Class name got renamed to 'Class009' under Package explorer as shown below -


Hence use 'Refactor' -> 'Rename' option to rename Project, Package and Class in Eclipse IDE.


Please comment below to feedback or ask questions.

Finding the Projects location in Eclipse IDE will be explained in the next post. 





No comments: