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:
- In the Projects window or the Source Editor window, right-click the class
and choose Refactor > Move Class from
the contextual menu.
- 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.
- (Optional) If you do not want to review the changes before they are made,
clear the Preview All Changes checkbox.
- Click Next. If you have cleared the Preview All Changes checkbox, the IDE applies
the changes automatically and skips the remaining steps.
- 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.
- (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.
- Click Do Refactoring to apply the selected changes.
- You can also initiate the moving of a class by dragging a class's node
in the Projects window to another package's node or by cutting and pasting a class's node.
To move a class without doing refactoring:
- 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.
- In the Move Class dialog box, select the Move Without Refactoring checkbox.
- Clear the Preview All Changes checkbox.
- Click Next.
- You should always perform a clean build after completing
any refactoring commands. You can do a clean build by right-clicking the project's
node in the Projects window and choosing Clean and Build Project.
- See Also
- Renaming a Class or Interface
- Finding Class, Method, and Field Usages
- Undoing Refactoring Changes
Legal Notices