Specifying target servers for J2EE projects

When you develop J2EE applications, you can specify the server runtime environments for your J2EE projects. The target server is specified during project creation and import, and it can be changed in the project properties. The target server setting is the default mechanism for setting the class path for J2EE projects.

In order to support different application servers that use different JDK levels for their Java™ Runtime Environment (JRE), the workbench prompts you for a target server setting for each J2EE project. For example, if you want to take advantage of the features of JDK 1.4.2, your applications require different class path entries than those that were used in previous versions of the workbench. By prompting you to specify a target server, the workbench enforces that proper entries are added for running on the server you choose.

You can also add more than one target server for your project. In this case, the workbench prevents you from adding any facets not supported by all of the target servers. If you add more than one target server, choose a server that will contribute to the project's class path as the primary server.

When the project is created, the class path of the project is updated with two class path containers. One container is the JDK container and the other is the server container. The JDK container points to the directory that contains the JAR files that are necessary to support the JDK version. The server container points to the directory that contains the multiple public JAR files available in the selected server. The project then compiles based on the required JAR files located in these folders, and you do not need to worry about adding additional JAR files from the server during development. When the project is compiled, the JAR files are included in the class path. You can still add your own JAR files to the class path.

The target runtime environment is specified in the org.eclipse.wst.common.project.facet.core.xml file in the project's .settings folder. You should not edit this file manually; instead, use the properties window as described in this topic.

All J2EE project creation and import wizards prompt you to specify the target server for the resulting projects. The list of target servers that you can choose from is filtered based on installed runtimes, the J2EE level of the application, and the J2EE module type. For example, for EJB projects only application servers that support Enterprise JavaBeans™ are displayed. All projects inside a single EAR file must be targeted to the same server. If you create a new project and add it to an existing EAR project during creation, the project inherits the target server setting of the EAR project.

Note: Utility Java projects that are added to an application are targeted to the same target server as the application. Web library projects that are added to a Web project are targeted to the same target server as the Web project.

To modify the target runtime and default server for an existing project, complete the following steps:

  1. In the Project Explorer view of the Java EE perspective, right-click the enterprise application or module project, and select Properties.
  2. Select the Targeted Runtimes page in the Properties dialog.
  3. In the Targeted Runtimes list, select the check boxes next to each of the runtimes that you want to develop the project for. If you don't see the runtime that you want to use, you need to add it to the runtimes in the workbench. For more information, see Defining the installed server runtime environments.
    Note: Only the runtimes compatible with the project's facets are shown. You can select the Show all runtimes check box to display the runtimes not compatible with the project's current facet configuration. These runtimes are grayed out.
  4. To select the primary runtime, click on a runtime and then click the Make Primary button. If you select any runtimes for the project, you must make one of those runtimes the primary runtime for the project. If you select only one runtime from the list, that runtime is automatically made the primary runtime. The primary runtime is shown in bold text.
  5. Click OK.

Related concepts
J2EE architecture
Related information
Defining the installed server runtime environments