Understand classpath and module dependencies

Specifying dependent JAR files or modules

You can use the JAR Dependencies 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.

When you are specifying required JAR files or modules, you first specify the enterprise application (EAR) that your project is a part of. Usually, the project will be referenced by one EAR project in the workspace. However, it is possible that you will have multiple enterprise applications that contain a reference to the same module or utility JAR project. If this is the case, then you should ensure that you give the JAR or module the same URI in each application, so that the class path will be 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 JAR Dependency editor to update the dependencies.

To specify the JAR files or modules in an enterprise application that are required by a module:

  1. In the Project Explorer view of the J2EE perspective, right-click your project's META-INF/MANIFEST.MF file, and select Open With > JAR Dependency Editor from the pop-up menu. The META-INF/MANIFEST.MF file is located in the following locations for the different module types:

    • EJB projects - ejbModule/META-INF/MANIFEST.MF

    • Application client projects - appClientModule/META-INF/MANIFEST.MF

    • Dynamic 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 JAR Dependency Editor.

  2. In the Classpath Scope section of the editor, select the enterprise application to use for class path editing. Because the JAR dependency editor is designed for class path editing, not all of the attributes or information contained in the manifest file (MANIFEST.MF) are represented on the 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.

    JAR Dependencies 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 will not show any EJB client JAR files. If you select the Use EJB client JARs radio button, the table will 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 will switch to the appropriate EJB client JAR file. If you select the Allow both radio button, none of your dependency selections will change automatically.

    Manifest-Version: 1.0
    Class-Path: bank.jar
    								

  4. Click File > Save to save your changes.

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.

Professional hosting     Belorussian informational portal         Free SCBCD 1.3 Study Guide     Free SCDJWS 1.4 Study Guide     SCDJWS 1.4 Quiz     Free IBM Certified Associate Developer Study Guide     Free SCJP 5.0 (Tiger) Study Guide     Free Mock Exam Engine     Free SCWCD 1.4 Study Guide     IBM Test 000-287. Enterprise Application Development with IBM WebSphere Studio, V5.0 Study Guide