Moving a Class to Another Java Package

See Also

To move a class to another package and to change the code that references that class:

  1. In the Projects window or the Source Editor window, right-click the class and choose Refactor > Move Class from the contextual menu.
  2. In the Move Class dialog box, select the package from the To Package combo box or type the fully qualified package name, such as com.myCom.myPkg.
  3. (Optional) If you do not want to review the changes before they are made, clear the Preview All Changes checkbox.
  4. Click Next. If you have cleared the Preview All Changes checkbox, the IDE applies the changes automatically and skips the remaining steps.
  5. The Refactoring window displays the lines of code that will be changed. Review the list and clear the checkbox of any code that you do not want changed.
  6. (Optional) Double-click a file name in the Refactoring window to open the file, or double-click a line of code to open the source file and to position the cursor on that line of code.
  7. Click Do Refactoring to apply the selected changes.

To move a class without doing refactoring:

  1. In the Projects window, manually move the class to another package.

    You can cut and paste the class, or you can use drag and drop.

  2. In the Move Class dialog box, select the Move Without Refactoring checkbox.
  3. Clear the Preview All Changes checkbox.
  4. Click Next.
See Also
Renaming a Class or Interface
Finding Class, Method, and Field Usages
Undoing Refactoring Changes

Legal Notices