HPCJ uses the Java Native Interface (JNI) as its native method interface. It provides header files in the include subdirectory of the distribution. JNI native methods must be packaged into a DLL and loaded using the System.loadLibrary() method.
Building Native Method DLLs
Consult your C
or C++ compiler documentation for details on building a DLL. The
name of the DLL should be file.dll, where file
is the name passed to System.loadLibrary(). If you are using the
IBM VisualAge C++ product, ensure that you include the /Ge-
option on the compile step.
Ensure
that you update the PATH setting to include the location of the
DLL.
Ensure
that you update the LIBPATH,
BEGINLIBPATH, and ENDLIBPATH settings to include the location of
the DLL.
Compile
your native methods using the C or C++ compiler. The name of the
library should be libfile.so, where file is the
name passed to System.loadLibrary(). For C, use the ld
command for the link step. For C++, use the makeC++SharedLib
command for the link step. The names of the native methods must
be exported on the link step. For the ld
command, use the -bE:FileId option to export the
names. For the makeC++SharedLib command, use the
-E:FileId option to export the names. Consult
the command documentation for more details on building a library.
Also ensure that you update the LD_LIBRARY_PATH setting to
include the location of the library.
Building Applications Using the JNI Invocation
Interfaces
C code that creates a VM using the JNI invocation interface must
be relinked using the HPJ-supplied libraries. (Recompilation is
only necessary if you want to use HPCJ specifics of the interface
or if you are not using the JDK 1.1 argument layout.) This only
applies to code that uses the invocation interface and not to
native code DLLs. The invocation code may also have to change to
take into account differences in the arguments supplied on the
JNI_CreateJavaVM() and related calls.