Creating a Project


Before you can do any serious work in the IDE, you need to set up a project. The project essentially sets up a context for you to write, compile, test, and debug your application. This context includes the classpath; folders for your sources and tests; and a build script with targets for compiling the application, running tests, and building JAR files (or other types of distributable archive files).

You can choose among a variety of project template categories, which are grouped according to the technology you are basing your application on (for example, general Java, Java EE web tier, Java EE enterprise tier, and Java ME).

Within the template categories, there are templates for new applications and for setting up an IDE project for existing applications you are working on. The New Project wizard provides a description for each template.

The With Existing Sources templates in each category enable you to set up standard IDE projects around applications that you have been developing in a different environment.

The With Existing Ant Script templates in each category, unlike the With Existing Sources templates and other standard project templates, enable you to set up a project based entirely on any existing Ant script. This approach requires some manual configuration to get some IDE features (such as debugging) to work with the Ant script, but the payoff is that you can get the IDE to work with any project structure, even if it does not adhere to the conventions of a standard IDE project. See Chapter 16 for information on creating a project with a With Existing Ant Script template.

To set up a project:

  1. Choose File | New Project.

  2. In the wizard, select a template for your project, and complete the wizard.

    The fields that you are asked to fill in depend on the template. Typically, you need to specify a location for the project (or, in the case of projects that use existing sources, where the sources are located). Web, Enterprise, and Mobility projects also include fields relevant for those specific types of applications. Figure 2-1 shows the Name and Location page of the wizard for a new web application project.

Figure 2-1. New Project wizard, Web Application template, Name and Location page


When you create a project, typically, the IDE does the following things for you:

  • Creates a source tree with a skeleton class inside.

  • Creates a folder for unit tests.

  • Creates an Ant build script (build.xml), which contains the instructions that the IDE uses when you perform commands on your project, such as compiling source files, running the application, running tests, debugging, compiling Javadoc documentation, and building JAR files.

You can find more information on setting up standard projects in Chapter 3. You can find more information on setting up free-form projects (those using the With Existing Ant Script template) in Chapter 16.

Projects Window

The Projects window is essentially the command center for your work. It is organized as a tree view of nodes that represent parts of your project. It provides an entry point for your files and configuration options for the application you are developing.

In addition to displaying nodes for the files in the application that you are developing, the Projects window provides a representation of your classpath. The Libraries node for each project shows the version of the JDK you are developing against, as well as any other libraries you are basing your project on.

The Projects window presents your project in "logical" formthat is, it represents the units of your application conceptually (rather than literally). For example, Java sources are grouped into packages without nodes for each level of file hierarchy. Files that you do not normally need to view, such as compiled Java classes and project metadata files, are hidden. This makes it easier to access the files you most regularly work with.

If you want to browse the physical structure of the project, including the project metadata, compiled classes, JAR files, and other files created in builds, open the Files window.




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