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 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.
- If you click Refactor, the IDE applies
the changes automatically and skips the remaining steps. If you click Preview,
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. If the
class that you are pushing members from has multiple subclasses and you do not
want the members to be pushed to all of them, be sure to clear the checkboxes
for the corresponding subclasses. 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.
- 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