Moving or Copying a File or Folder

When you move or copy a file or folder in your Java project, the file or folder on the hard disk is also moved or copied. Moving or copying a folder also moves or copies all project files in the folder.

Important   When moving or copying a .java file to a different folder, you must manually change its package statement to reference the new package. (Note that the project node itself is considered the default package.) Similarly, if you move a folder within the project, you must manually change the package statement of each .java file in the folder. If a file's package statement does not map to the folder it resides in, the output directory structure will not match the source directory structure when you build the project.

When moving or copying items, Project Explorer follows the rules of the file system. For example, you cannot move a folder into any of its subfolders.

To move or copy a file or folder in the project

  1. In Project Explorer, right-click the name of the file or folder to be moved or copied.

  2. To move the item, click Cut on the shortcut menu; to copy the item, click Copy.

  3. Right-click the new folder or the project node that will contain the file or folder.

  4. On the shortcut menu, click Paste.

Note   If a file or folder is moved or copied through the file system, it is automatically moved or copied within Project Explorer. However, you must still ensure that the package statements in the .java files are correct.

You can also copy files and folders by dragging them in Project Explorer. Note that drag-and-drop operations in Project Explorer only copy the source items. In directory view, you can drag either a single folder or any set of files. In package view, you can only drag files. For more information about views, see Choosing the Project View.