How to change the package name in eclipse

Written by sue smith Google
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to change the package name in eclipse
Java development in Eclipse automates the changing of package names. (Java hot and black image by Pix by Marti from Fotolia.com)

When you develop Java applications in Eclipse, there may be times when you need to make changes to the details of a project you're working on, such as the package name. Changing project details in Eclipse can seem difficult at times, but there are actually only a few steps required. If you carry out the steps in the correct sequence, you can get your package name updated quickly.

Skill level:
Easy

Other People Are Reading

Instructions

  1. 1

    Open Eclipse. Click on the "Window" menu from the top Eclipse toolbar, select "Show View," then "Package Explorer." The Package Explorer panel should become visible and normally appears down the left side of your window. Look down the list of projects in the Package Explorer until you find the one you want to change.

  2. 2

    Open the folder for your project by clicking on the arrow next to it. Open the internal folder called "src" by clicking on the arrow next to it. If you have more than one package in your project, scroll down until you find the one you want to change. Open the "Refactor" menu by right-clicking on your package and moving the mouse to it, or by selecting the package and opening the "Refactor" toolbar menu.

  3. 3

    Open the renaming dialogue by selecting "Rename" in your "Refactor" menu. The "Rename Package" window will open. Edit the name in the text box. Remember to include dots between the elements and watch for any error messages that appear as you type in the new name. Check the "Update References" and "Rename Subpackages" boxes if they are not already checked. Click "OK."

  4. 4

    Save your files and compile your project to test it. To save, press "Ctrl" and "S" while each file is open or choose the "File" menu and select "Save." To compile the project, choose the "Run" menu, then "Run Configurations." Select the project and press the "Run" button. Make sure your application still functions correctly following the renaming.

  5. 5

    Clean your project if there are errors. Right-click on the project folder and choose "Source," then "Clean Up." Alternatively, you can select the project, choose the "Source" menu from the toolbar and select "Clean Up." Save and compile your Project again before testing it thoroughly.

Tips and warnings

  • It's better to use the Refactoring capabilities in Eclipse than to try renaming elements manually, as Eclipse will automatically filter the changes through to each element in a project.
  • If you decide not to go ahead with the renaming, you can undo it by choosing "Undo Rename Package" in the "Edit" menu immediately after carrying out the renaming process.
  • There is always a risk that something will go wrong when you rename elements in an Eclipse project, so make sure you have everything backed up.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.