Adding third-party libraries to JDeveloper projects

During a project, we usually integrate third-party libraries to perform various tasks, for example, calculating the digest value or connecting to the credit card gateway. This recipe will explain how to add third-party libraries into JDeveloper projects. Since the book scope aims at BPEL and Java, we will be most interested in how to include third-party libraries to be utilized in BPEL processes. When we use third-party libraries only in one BPEL process, then we can deploy a third-party library in the BPEL process deployment package. When multiple BPEL processes are using the same third-party libraries, then we can deploy them as described in the Adding third-party libraries to the SOA Suite server recipe to avoid unnecessary redundancy.

Getting ready

We will add the same third-party library to JDeveloper as we did in the Adding third-party libraries to the SOA Suite server recipe; that is, Apache Commons Codec.

How to do it…

To add third-party libraries to the JDeveloper project, we need to copy the libraries to the SCA-INF/lib directory. That way, the libraries are included in the build phase and deployment phase of the project.

How it works…

The SOA projects in JDeveloper have a placeholder (SCA-INF/lib) where we put the libraries. This also ensures that libraries are picked by the make process that packs the libraries into the deployment package.

There's more…

The procedure we described in this recipe can be taken into account when we don't have the same set of libraries already deployed in the Oracle SOA Suite server. In cases where the libraries already exist in the Oracle SOA Suite server, we have other options with which to add libraries to the JDeveloper projects. The following two procedures describe the user-defined libraries in JDeveloper and reference the libraries from the JDeveloper project properties. In these scenarios, we reference the third-party libraries and use them inside the BPEL process; however, we don't pack them into the BPEL process deployment package.

Creating a user-defined library and referencing it inside a JDeveloper project

The user libraries in JDeveloper present a group of JARs packed into contextually similar definitions, for example, BPEL Runtime, SOA Runtime, and so on:

  1. Right-click on the project and select Project Properties. From the tree in the dialog, select Libraries and Classpat and then click on the Add Library... button as shown in the following screenshot:
    Creating a user-defined library and referencing it inside a JDeveloper project
  2. In the Add Library window, click on the New... button.
  3. In the Create Library dialog, enter the name of the library. The location of the library specifies whether the library is a project or user-oriented. Then click on the Add Entry... button on the class, source, or doc path. We have all three JARs, so we add all the relevant libraries as shown in the following screenshot:
    Creating a user-defined library and referencing it inside a JDeveloper project
  4. Click on the OK button. We will see that our library appears under the user-defined libraries. Again, click on the OK button. We will see that our library is automatically added to the project libraries. Once again, click on the OK button.

Adding libraries from the JDeveloper project properties

This procedure is useful in cases where we don't have multiple JARs to be references and defining a user-defined library presents a work overhead. We are referencing the third-party library directly from the project. Right-click on the project and navigate to Project Properties. From the tree in the dialog, select Libraries and Classpath and then click on Add JAR/Directory... At the opened dialog, search for the library and click on the Select button as shown in the following screenshot:

Adding libraries from the JDeveloper project properties

New library now appears under the classpath entries in the project properties dialog.

See also

We will examine how to add classes to JDeveloper projects in the next recipe. We saw the usage of the third-party libraries in the last two recipes.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset