NonStop Server for Java 4.2 Programmer's Reference

unless you have a JNI_OnLoad function or you use the -Dcompaq.liblist option when your run
java.
On TNS/E systems, the library name (name) that is passed to the System.loadLibrary method is
converted to:
libname.so
to create the name of the DLL to be loaded. For example, the name stats passed to the
System.loadLibrary method, is converted to libstats.so.
The remainder of this subsection explains:
Calling C or C++ Methods from Java
Calling Java Methods from C or C++
Using the compaq.liblist System Property (TNS/R Only)
Linker and Compiler Options
For more information about JNI, see the Sun Microsystems JNI document
(http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html).
Calling C or C++ Methods from Java
To call C or C++ methods from Java, follow these steps:
Compile the Java code.1.
Use javah to generate header files. On TNS/E systems, the function declarations listed in the generated
header file are those that must be exported by the user-JNI DLL. To export functions, either specify
export$ in the function definition or use the linker option -export_all.
2.
Compile the C or C++ code. C++ code must be compiled using the following compiler command-line
options: -Wversion3 for TNS/R, -Wversion2 or -Wversion3 for TNS/E, and -WIEEE_float.
If the native code has large variables on the stack, calling this native code might exceed the default stack
space provided for each thread. If the native code exceeds the amount of stack space allocated for it,
unpredictable results can occur. To prevent overflowing the available stack space, consider allocating large
variables on the heap rather than using the stack. Otherwise, you can increase the default stack size for each
thread by specifying the -Xss option when starting java. This option increases the stack size for every
thread. For more information about the -Xss option, see java in the NonStop Server for Java Tools
Reference Pages.
3.
The steps depend on the system type.
On TNS/R, create either a relinkable library (.lib) file or an archive library (.a) file and specify the
linker option set floattype IEEE_float. Go on to steps 5 and 6.
On TNS/E systems, create a DLL file (.so file type) and specify the linker option -set
floattype IEEE_float. Then set the _RLD_LIB_PATH environment variable to point to
where the created DLL file resides by using the following command:
export _RLD_LIB_PATH=dll-path
where dll-path is the directory where the user DLL resides. For more information, see
_RLD_LIB_PATH (TNS/E Only).
4.