Moving and copying Java elements

In this section, you will move a resource between Java packages.
 
1.
In the Package Explorer view, select the MyTestCase.java file and drag it into the junit.framework package. The file is moved, and its package declaration changes to reflect the new location.
Editor with updated package declaration
2.
Select the MyTestCase.java file and drag it into the root directory of the JUnit project. A default package is created to contain the class, and the package declaration is removed to reflect its new location.
Editor without package declaration
3.
Using the context menu is an alternative to drag and drop:
Select the MyTestCase.java file and from its context menu, select Refactor > Move. In the Move dialog, expand the hierarchy to browse the possible new locations for the resource. Select the junit.framework package, then click OK. The class is moved, and its package declaration is updated to the new location.
Move destination dialog
Note: This example did not result in compile errors. However, moving a compilation unit can lead to compile errors because import statements are not updated when a compilation unit is moved.