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:
- Create a
lib
folder in your project. - Add the third-party JAR files into the
lib
folder. 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,
- Add them to your project build for Eclipse.
- 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:
- Add the
so
files into alib
folder in your project – refer tolibCallDcm.so
: 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.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:
- Add the DLL files into a
lib
folder in your project – refer tolibCallDcm.dll
andzlib1.dll
:
Note that in this example,zlib1.dll
is required bylibCallDcm.dll
. Put all dependencies into thelib
folder. In your Java code, load the libraries in reverse order. For example, if you want to load
libCallDcm.dll
, which is dependent onzlib1.dll
, then loadzlib1.dll
first:System.loadLibrary("zlib1.dll"); // zlib1.dll System.loadLibrary("libCallDcm"); // libCallDcm.dll
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