Adding Third-party Libraries to a Custom Component

You can add third-party libraries to your custom filter or communication point:

Third-party Java Libraries

To add logging to your filter using third-party JAR files (log4j.jar) into our custom module:

  1. Create a lib folder in your project.
  2. Add the third-party JAR files into the lib folder.
  3. Add the JAR files to the path in your MANIFEST.MF file, comma-separated (it is recommended you use the visual editor rather than editing the file directly – use runtime tab and classpath entry):

    Bundle-ClassPath: .,
    lib/commons-cli-1.2.jar,
    lib/dcm4che-audit-2.0.25.jar,
  4. Add them to your project build for Eclipse.
  5. Ensure your Ant script that creates the module JAR also includes them.

Third-party System Libraries (.so) on Linux

To add 'system libraries' such as shared library objects (*.so) in Linux:

  1. Add the so files into a lib folder in your project – refer to libCallDcm.so:
  2. Load the shared library in your Java code. Here, check if it is a Linux instance as the syntax is slightly different for Windows:

    // Linux                 
    if (System.getProperty("os.name").toLowerCase().equals("Linux".toLowerCase())){
        System.loadLibrary("CallDcm"); // libCallDcm.so
    }
    // Windows
    else {
        System.loadLibrary("zlib1.dll");  // zlib1.dll
        System.loadLibrary("libCallDcm"); // libCallDcm.dll
    }

    Note for Linux how we omit lib and .so as you would for any native use of libraries.

  3. Modify your MANIFEST.MF to reference the library by adding a Bundle-NativeCode line:

    •  For 64-bit Linux, add the following line:

      Bundle-NativeCode: lib/libCallDcm.so; osname=Linux; processor=amd64
    • If you have both Windows and Linux support, add the following line (all on one line):

      Bundle-NativeCode: lib/libCallDcm.so; osname=Linux; processor=amd64, lib/zlib1.dll; lib/libCallDcm.dll; osname="Windows Server 2008"; osname="Windows 7"; processor=amd64; processor=x86_64

Third-party system libraries (.dll) on Windows

To add 'system libraries' such as DLLs in Windows:

  1. Add the DLL files into a lib folder in your project – refer to libCallDcm.dll and zlib1.dll:

    Note that in this example, zlib1.dll is required by libCallDcm.dll.  Put all dependencies into the lib folder.
  2. In your Java code, load the libraries in reverse order. For example, if you want to load libCallDcm.dll, which is dependent on zlib1.dll, then load zlib1.dll first:

    System.loadLibrary("zlib1.dll"); // zlib1.dll
    System.loadLibrary("libCallDcm"); // libCallDcm.dll
    
  3. Modify your MANIFEST.MF to reference the library by adding a Bundle-NativeCode line. For 64-bit Windows, add the following line:

    Bundle-NativeCode: lib/libCallDcm.dll; osname="Windows Server 2008"; osname="Windows 7"; processor=amd64; processor=x86_64