Specifying dependent JAR files or modules

You can use the Manifest editor to specify JAR files or modules that are required by a module. The dependencies are defined in the MANIFEST.MF file for your module.

About this task

When you are specifying required JAR files or modules, you first specify the enterprise application (EAR) that your project is a part of. Typically, the project is referenced by one EAR project in the workspace. However, it is possible that you have multiple enterprise applications that contain a reference to the same module or utility JAR project. If so, then you should ensure that you give the JAR or module the same Uniform Resource Identifier (URI) in each application, so that the class path is valid for all applications.

It is also possible that your module is a standalone project and is not currently referenced by any enterprise application. In this case, since there is no enterprise application scope defined, you cannot use the Manifest editor to update the dependencies. To add the module to an enterprise application, see Adding modules to an enterprise application.

Procedure

  1. In the Enterprise Explorer view of the Java™ EE perspective, right-click your project's MANIFEST.MF file, and select Open With > Manifest Editor from the pop-up menu. The MANIFEST.MF file is located in the following locations for the different module types:
    Project type Location of manifest file
    EJB projects ejbModule/META-INF/MANIFEST.MF
    Application client projects appClientModule/META-INF/MANIFEST.MF
    Web projects WebContent/META-INF/MANIFEST.MF
    Connector projects connectorModule/META-INF/MANIFEST.MF
    Tip: For application client modules, you can also click Edit in the Main Class section of the Client Deployment Descriptor editor to launch the Manifest Editor.
  2. In the Classpath Scope section of the editor, select the enterprise application to use for class path editing. Because the Manifest editor is designed for class path editing, not all the attributes or information contained in the manifest file are represented on this page. The Classpath Scope section lists all enterprise applications that contain a reference to the selected project as a module or utility JAR. Use the Refresh button to update the list if a change is made in a separate editor.
  3. In the Dependencies section, select the JAR files or modules that are required or dependent. You can also move them up and down in the list to specify their order on the MANIFEST class path as well as the Java build path.

    In cases where your module depends on an EJB module that has an EJB client JAR file, you can choose whether you want to depend on the EJB JAR file or the EJB client JAR file. If you select the Use EJB JARs radio button, the table does not show any EJB client JAR files. If you select the Use EJB client JARs radio button, the table does not show any EJB JAR files that have corresponding EJB client JAR files. If you select the Allow both radio button, the table shows EJB JAR files and EJB client JAR files and allows you to select both types.

    Tip: The Dependencies section automatically switches dependencies based on which radio button you select. For example, if you have a dependency set on an EJB JAR file and you select the Use EJB client JARs radio button, the dependency switches to the appropriate EJB client JAR file. If you select the Allow both radio button, none of your dependency selections change automatically.
  4. In the Implementation Version section, type the version of the module you are implementing.
  5. In the Annotation Scanning section, you can specify archives and packages that you want to exclude from annotation scanning. For more information on annotation scanning see: Excluding files from annotation scanning.
  6. In the Main Class section, you can use the manifest editor to set the main Java class as the entry point for the application.
  7. Click File > Save to save your changes.

Results

Tip: If you need to compile against a server's runtime JAR files during development, you do not need to add these JAR files as dependent JAR files. The workbench manages this by using the target server property for the project. The workbench adds the appropriate libraries to your project's build and class path based on the target server. For more information, see Specifying target servers for J2EE projects.

Feedback