{"id":2128,"date":"2018-05-25T10:36:00","date_gmt":"2018-05-25T10:36:00","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=2128"},"modified":"2024-08-09T09:05:33","modified_gmt":"2024-08-09T09:05:33","slug":"how-to-rename-a-class-in-eclipse-ide","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-rename-a-class-in-eclipse-ide\/","title":{"rendered":"How to rename a class in Eclipse IDE?"},"content":{"rendered":"<h1>How to rename a class in Eclipse IDE?<\/h1>\r\n<p>In this post, we will learn how to rename a class in Eclipse IDE. This is useful when we want to refactor a class name in a Java Project.\u00a0<\/p>\r\n<p>Environment:<\/p>\r\n<ul>\r\n<li>Eclipse IDE<\/li>\r\n<li>Windows Operating System<\/li>\r\n<\/ul>\r\n<h2>Steps to Rename a Class<\/h2>\r\n<p>Launch Eclipse IDE. There are multiple ways to launch the Eclipse IDE.<\/p>\r\n<p>Select the Java project and the class to be renamed in the <strong>Project Explorer<\/strong>.<\/p>\r\n<p>Right-click the mouse on the class name and choose the following option from the context menu option:<\/p>\r\n<p><em>Refactor &gt;&gt; Rename&#8230;<\/em><\/p>\r\n<p>This will open a new window called\u00a0 <strong>Rename Compilation Unit<\/strong>.<\/p>\r\n<p>Alternatively, we can press the keyboard shortcut <em>Alt + Shift + R.<\/em><\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21698\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Rename-Class-in-Eclipse.png\" alt=\"Rename Class in Eclipse\" width=\"1920\" height=\"1079\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Rename-Class-in-Eclipse.png 1920w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Rename-Class-in-Eclipse-300x169.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Rename-Class-in-Eclipse-1024x575.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Rename-Class-in-Eclipse-768x432.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Rename-Class-in-Eclipse-1536x863.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\r\n<p>&nbsp;<\/p>\r\n<p>Keep the option checked in the checkbox <strong>Update references.\u00a0<\/strong>This option will automatically rename any references of the class in other class files.\u00a0<\/p>\r\n<p>Choose the new name for the Java class. Click on the <strong>Next &gt;<\/strong> button.<\/p>\r\n<p>&nbsp;<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21699\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Enter-New-Class-Name-Eclipse.png\" alt=\"Enter New Class Name Eclipse\" width=\"1920\" height=\"1001\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Enter-New-Class-Name-Eclipse.png 1920w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Enter-New-Class-Name-Eclipse-300x156.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Enter-New-Class-Name-Eclipse-1024x534.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Enter-New-Class-Name-Eclipse-768x400.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Enter-New-Class-Name-Eclipse-1536x801.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/p>\r\n<p>&nbsp;<\/p>\r\n<p>Eclipse would show a preview the changes. The original source on the left tab, the refactored source on the right tab. For example, HelloWorld class name was renamed to new HelloWorldDemo<\/p>\r\n<p>&nbsp;<\/p>\r\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21702\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Refactored-Source-Eclipse.png\" alt=\"Refactored Source Eclipse\" width=\"1912\" height=\"1076\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Refactored-Source-Eclipse.png 1912w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Refactored-Source-Eclipse-300x169.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Refactored-Source-Eclipse-1024x576.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Refactored-Source-Eclipse-768x432.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Refactored-Source-Eclipse-1536x864.png 1536w\" sizes=\"auto, (max-width: 1912px) 100vw, 1912px\" \/><\/p>\r\n<p>&nbsp;<\/p>\r\n<p>Click on the <strong>Finish<\/strong> button on the<strong> Rename Compilation Unit<\/strong> screen.<\/p>\r\n<p>Eclipse would rename the class name with the updated new name. That&#8217;s it. We have successfully renamed a java class in Eclipse IDE.<\/p>\r\n<p>&#8212;<\/p>\r\n<h2>Java Tutorials<\/h2>\r\n<p>Java Tutorial on this website:<\/p>\r\n<p><a href=\"https:\/\/www.testingdocs.com\/java-tutorial\/\">https:\/\/www.testingdocs.com\/java-tutorial\/<\/a><\/p>\r\n<p>More information on Java can be found on the official website:<\/p>\r\n<p><a href=\"https:\/\/www.oracle.com\/in\/java\/\" rel=\"noopener\">https:\/\/www.oracle.com\/in\/java\/<\/a><\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>How to rename a class in Eclipse IDE? In this post, we will learn how to rename a class in Eclipse IDE. This is useful when we want to refactor a class name in a Java Project.\u00a0 Environment: Eclipse IDE Windows Operating System Steps to Rename a Class Launch Eclipse IDE. There are multiple ways [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[22],"class_list":["post-2128","post","type-post","status-publish","format-standard","hentry","category-eclipse","tag-eclipse","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=2128"}],"version-history":[{"count":15,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2128\/revisions"}],"predecessor-version":[{"id":23847,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2128\/revisions\/23847"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=2128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=2128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=2128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}