Navigating Your Projects


Once the project is set up, your files are accessible from both the Projects window and the Files window.

Projects Window

The Projects window (shown in Figure 3-6) is designed to be the center of operations for file creation, project configuration, and project building. The Projects window displays only the files that are likely to be regularly edited in a project, such as Java source files, web pages, and tests. Build outputs and project metadata are ignored.

Figure 3-6. Projects window


Java sources are displayed according to package structure, which generally makes it easier to navigate to files because you do not have to navigate through nested folder hierarchies.

The main node for each project has commands on its contextual (right-click) menu for compiling, running, debugging, creating Javadoc, and performing other project-related actions.

Files Window

The Files window displays your files organized according to file hierarchy, much as they appear in a file manager on your system. (One exception to this is that the .form files that are used to generate the design view of GUI classes that you create in the IDE's Form Editor are not displayed; just the .java file is displayed.) In addition to your sources, tests, and web files, project metadata and files produced when you build the project appear. See Figure 3-7.

Figure 3-7. Files window


The Files window is useful if you need to browse the physical structure of your project, such as the contents of the JAR file (or other archive file) produced by the project. The Files window also provides direct access to project metadata files if you need to customize them. Otherwise, it is probably best to work in the Projects window, because project-related commands are not available in the Files window.

If you prefer a physical view of your files but do not want to see the top levels of the file hierarchy that are necessitated by the Java package structure, you can use the Favorites window. See Working with Files Not in the Project later in this chapter.

You can also set the Projects window to display files according to file hierarchy instead of by package. Choose Tools | Options and click General in the left side of the window. Then select the View Java Packages as Tree radio button.


Fast Navigation Between the Projects and Files Windows

If you are working with a node in one window but want to switch to that node in a different window, there are several keyboard shortcuts available to speed navigation. For example, if you have been working in the Projects window and now want to inspect the build script (which, in standard projects, is viewable through the Files window), you can jump straight to the project's node in the Files window without having to scroll to the node. See Table 3-2 for some of the shortcuts that are particularly useful for navigating between the "explorer"-style windows.

Table 3-2. Shortcuts to Select the Current File's Node in a Different Window

Keyboard Shortcut

Action

Ctrl-Shift-1

Open the Projects window and display the node that corresponds to the currently selected file, package, or folder.

Ctrl-Shift-2

Open the Files window and display the node that corresponds to the currently selected file, package, or folder.

Ctrl-Shift-3

Open the Favorites window and display the node that corresponds to the currently selected file, package, or folder.


You can also use these shortcuts in the Source Editor when you want to jump to the node for that file.

Physical Structure of IDE Projects

The Projects window provides a "logical" view of projects that is oriented toward coding activities and does not include all files in the project. For example, output files (such as compiled classes and JAR files), project metadata, and version control metadata files (if you are using version control) are hidden.

If you want to see the actual files created in the project, open the Files window (by clicking the Files tab above the Projects window).

When you create a general project (using a standard template), the IDE creates the following folders and files:

  • nbproject folder, which includes files that store data about your project and are used to create the build script for your project.

  • src folder, which holds your source files (assuming the IDE project was not created with existing sources). This folder corresponds with the Source Packages node that appears in the Projects window.

  • test folder, which holds any unit tests you create for your project. This folder corresponds with the Test Packages node that appears in the Projects window.

  • build.xml file, which is the Ant build script that is used when compiling, cleaning, running, and debugging your project. This file actually imports the build-impl.xml file, which is generated in the nbproject folder. See Inside the Generated Build Scripts later in this chapter for more information on the build script and files inside the nbproject folder.

When you build your project, the following folders are added:

  • build folder, which holds the compiled class files.

  • dist folder, which holds the packaged output for the project (a JAR file). If there are any JAR files on the project's classpath, the IDE creates the lib subfolder and places those JAR files there in order to simplify deployment of the finished application.

For web applications created from standard templates, the IDE creates the following folders and files:

  • nbproject folder, which includes files that store data about your project and are used to create the build script for your project.

  • src folder, which holds Java source files.

  • web folder, which typically holds the WEB-INF and META-INF folders, as well as any HTML pages, JSP pages, custom tag libraries, and other files for the web application.

  • build.xml file, which is the Ant build script that is used when compiling, cleaning, running, and debugging your project.

When you build your project, the following folders are added:

  • build folder, which holds the compiled class files.

  • dist folder, which holds the compiled application in distributable form (a WAR file).



NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net