# Creating EJB projects

An EJB project is used to organize the resources contained in an EJB module.

An EJB module is used to assemble one or more enterprise beans into a single deployable unit. It is deployed in a standard Java™ archive (JAR) file. An EJB module can be used as a standalone application, or it can be combined with other modules to create a Java EE enterprise application. An EJB module is installed and run in an enterprise bean container. An EJB project must be referenced by an enterprise application project (defined as a module in an EAR) in order to be deployed successfully and run on a server.

An EJB module contains the following:

- One or more deployable enterprise beans.
- A deployment descriptor, stored in an Extensible Markup Language (XML) file. This file declares the contents of the module, defines the structure and external dependencies of the beans in the module, and describes how the enterprise beans are to be used at run time.

To create a new EJB project, complete the following steps:

1. In the Java EE perspective, select File > New > Other.
2. In the New Project Wizard, select EJB > EJB Project and click Next.
3. In the Project Name field, type a name for the EJB project.
4. Optional: To use a different workspace directory for your EJB project, modify the settings for Project contents.
   Note: If you specify a non-default project location that is already being used by another project, the project creation will fail.
5. In the Target runtime drop-down list, select the application server that you want to target for your development. This selection affects the compilation and runtime settings by modifying the class path entries for the project. Use the New button if a target runtime does not exist, or if you want to use a different one.
6. In the EJB Module version field, select the correct version level for the project.
7. Select a pre-defined project configuration from the Configurations drop-down list, or modify the configuration to customize the project facets. You can select the Java version, support for XDoclet, and support for Java persistence when customizing your configuration.

   For example, if you are creating an Entity Bean, select the Java Persistence facet. You can save your configuration with a meaningful name so that you can reference this configuration in any EJB projects that are subsequently created.

8. Optional: Select the Add project to an EAR check box to add the new module to an enterprise application (EAR) project. Type a new project name or select an existing enterprise application project from the drop-down list in the EAR Project combination box. Or, click the New button to launch the New Enterprise Application Project wizard. Click Next.
   Note: If you type a new EAR project name, the EAR project will be created in the default location with the lowest compatible Java EE version based on the version of the project being created. If you want to specify a different version or a different location for the enterprise application, click New to use the New Enterprise Application Project wizard.
9. Optional: Change the value of Source Folder to change the directory where the Java source files are stored.
10. Optional: Select the Create an EJB Client JAR Project to hold the client interfaces and classes check box if you want the client interface classes for your enterprise beans to be kept in a separate EJB client JAR file. This EJB client JAR file will be added to the enterprise application as a project utility JAR file. You can also modify the Name of the EJB Client JAR project, or the name (Client JAR URI) of the client JAR file.
11. Click Finish.

Note: The New Project Wizard will automatically add default facets to your project. You can change these facets or add new ones in the Preferences window. For more information, see Adding a facet to a Java EE project.

- Creating a EJB 3.1 session bean using the wizard
  You can use the Create Session Bean wizard to create a session bean in your EJB project.
- Creating a message-driven bean using the wizard
  You can use the Create Message-Driven Bean wizard to create a message-driven bean in your EJB project.

Parent topic: Developing EJB 3.1 Applications
Parent topic: EJB 2.x development resources