Previous Next vertical dots separating previous/next from contents/index/pdf

Setting up JAR and J2EE Library Dependencies

This topic describes techniques for managing the location and availability of JARs and WebLogic J2EE Shared Libraries in your projects and enterprise applications.

The IDE builds projects using project source files as well as JARs that are stored in the project, or available on the build path. Within the IDE, virtual copies of J2EE modules may be stored in the project, rather than physical copies. After build, the resulting module is deployed to the server. Modules may access runtime libraries available on the class path.

There are two types of libraries that you can add to a project or application

For more information on J2EE libraries, consult your WebLogic Server documentation locally or online. J2EE libraries can be:

You can:

 

Adding JARs to Your Projects

You can add JARs to your projects by copying them to your project folders. Note that you may need to right click on the Package Explorer view and click Refresh to update the file list.

Option 1: Add a JAR to an Enterprise Application

JAR files copied into the EarContent/APP-INF/lib directory of an EAR project are added to the buildpath of all projects included in the EAR. You do not need to configure project dependencies on such JAR files. Objects in the JAR will simply appear in the IDE and they will be available at build and deployment for all projects in the EAR.

Option 2: Add a JAR to a Single Project

JAR files copied into the WebContent/WEB-INF/lib directory of a web project are added to the buildpath of that project. The contents of the JAR file will appear in the IDE and they will be available at build and deployment for that single project only.

Managing How Facets Make J2EE Libraries Available to Projects

When creating a project in Workshop for WebLogic, the project facets that are selected for the project determine what J2EE libraries are required. You may also add or remove project facets after a project is created. J2EE libraries can be handled one of two ways:

  1. Workshop for WebLogic allows you to use the WebLogic Server shared J2EE libraries feature which makes the J2EE libraries available on the build path but does not make copies of the J2EE libraries in every project where it is used.
  2. The J2EE standard method is to copy the JARs inside a J2EE library into the WEB-INF/lib folder of the project.

When you create a web project, one of the screens allows you to specify whether this project will share J2EE libraries (Use Shared J2EE Libraries) or create a copy of the J2EE libraries in the current project (Do not use Shared J2EE Libraries. Copy all required JARs into the WEB-INF/lib directory).

This setting is persistent and affects how WebLogic J2EE shared libraries are handled if you later add/remove facets using the Project Facets properties page.

 

Add Custom J2EE Libraries to your Projects

You may have access to other J2EE libraries that you want to use in more than one project. You can use these J2EE libraries in your projects by doing the following:

  1. Register the library with Workshop for WebLogic by clicking Window > Preferences > Weblogic > J2EE Libraries.

    Click Add to add a new library:

    When you have entered the library location, click OK to finish.

  2. Open Project Explorer view by clicking Window > Show View > Other > Basic > Project Explorer.
  3. For applications, expand Enterprise Applications in the Project Explorer. For projects, expand the project type (i.e., Dynamic Web Projects for web applications, Web Services for web service projects, etc.)
  4. Expand the project name.
  5. Expand the [WebLogic] object. For example, if your project is called MyEAR, you would expand MyEAR [WebLogic]
  6. Right click on the WebLogic J2EE Libraries object as shown below.

    Click Add from the popup menu.

  7. Enter the library path/name or browse for the library name. Click OK to accept.

 

Related Topics

none.

 

Skip navigation bar   Back to Top