Adding a facet to a J2EE project This topic explains how to add a facet to an existing project in your workspace. projectsfacetsadding projectsfacetsremoving projectsfacetsoverview J2EE developmentproject facets J2EE modulesproject facets

Facets define characteristics and requirements for projects. When you add a facet to a project, that project is configured to perform a certain task, fulfill certain requirements, or have certain characteristics. For example, the EAR facet sets up a project to function as an enterprise application by adding a deployment descriptor and setting up the project's classpath.

You can add facets only to J2EE projects and other types of projects that are based on J2EE projects, such as enterprise application projects, dynamic Web projects, and EJB projects. You cannot add facets to a Java project or plug-in project, for example. Typically, a facet-enabled project has at least one facet when it is created, allowing you to add more facets if necessary. For example, a new EJB project has the EJB Module facet. You can then add other facets to this project like the EJBDoclet (XDoclet) facet.

Some facets require other facets as prerequisites. Other facets cannot be in the same project together. For example, you cannot add the Dynamic Web Module facet to an EJB project because the EJB project already has the EJB Module facet. Some facets can be removed from a project and others cannot.

New projects generally have facets added to them when they are created. To add another facet to a project that already exists, follow these steps:

In the Project Explorer view, right-click the project and then click Properties. In the Properties window, click Project Facets. The Project Facets page lists the facets in the project. Click Add/Remove Project Facets. In the Add/Remove Project Facets window, select the check boxes next to the facets you want this project to have and select a version number for each facet.

Only the facets that are valid for the project are listed:

  • The list of runtimes selected for the project limits the facets shown in the list. Only the facets compatible with all selected target runtimes are shown.
  • The currently selected facets and their version numbers limit the other facets shown in the list. For example, if the project contains the Dynamic Web Module facet, the EJB Module facet is not listed because these two facets cannot be in the same project.
You can find out more about the requirements and limitations for each facet by right-clicking the facet name and then clicking Show Constraints.

You can also choose a preset combination of facets from the Presets list.

To remove a facet, clear its check box.Not all facets can be removed. If you want to limit the project so it will be compatible with one or more runtimes, click the Show Runtimes button and select the runtimes that you want the project to be compatible with. For more information on runtimes, see . Click Finish. Click OK.