Adding a Folder

When you add a new folder to your project, a corresponding folder is created on the hard disk. In a Java project, a folder is essentially a Java package. In Project Explorer's directory view, all packages are displayed as project subfolders. In package view, subfolders are displayed as Java packages. For more information about views, see Choosing the Project View.

Note   A folder may reside in the project directory structure without belonging to the project. For example, removing a folder from the project still leaves the folder in the project directory structure. This folder can be added back to the project in its same location on the disk.

To add a new folder (package) to the project

  1. In Project Explorer, right-click the project or folder node that will contain the new folder.

  2. On the shortcut menu, click New Folder.

  3. In the Add Package/Folder dialog box, type the name of the new folder. This name must be a valid Java package name. For information about valid names, see Identifiers in the Java Language Specification.

  4. Click OK.

Once you have created a folder, you can add files to it. For information about adding files, see Adding a File.

Note   If a folder is added to the project directory structure through the file system, it is automatically added to the project and displayed in Project Explorer. All files in the folder, whose types are specified in the project filter, are added to the project as well. For more information about the project filter, see Displaying All Files in the Project Directory Structure.

Adding a Folder that Resides in the Project Directory Structure

If a folder does not belong to the project, but it already exists in the project directory structure, you can simply add it to the project in that same location.

To add a folder that already resides in the project directory structure

  1. Set the project view to directory view by clicking the Directory View button in Project Explorer. Only directory view allows you to see the nonproject items that reside in the project directory structure. For more information about views, see Choosing the Project View.

  2. If the nonproject items are not currently displayed, click the Show All Files button in Project Explorer to show all files and folders in the project directory structure.

  3. Right-click the name of the folder that you want to add to the project.

  4. On the shortcut menu, click Add To Project. The folder and all subfolders and files contained within the folder are added to the project. (Only those files whose types are specified in the project filter are added.)

  5. To hide any remaining nonproject items, click the Show All Files button again.

For more information about the project filter and about nonproject items that reside in the project directory structure, see Displaying All Files in the Project Directory Structure.