NonStop Server for Java 5.1 Programmer's Reference
The JNI_OnUnload function is supported by NonStop Server for Java 5.1 on NS-series servers, but not
supported on S-series servers.
●
When naming library files, observe the following rules:
Do not use names that begin with Tandem, tandem, or tdm.
●
NonStop Server for Java 5.1 requires that all DLLs be named with a prefix lib and a sufix .so. So you
must name your DLL as follows:
libname.so
where (name) signifies the string that is passed to the System.loadLibrary() call.
libname.so
●
The remainder of this subsection explains:
Calling C or C++ Methods from Java●
Calling Java Methods from C or C++●
Linker and Compiler Options●
For more information about JNI, see the Sun Microsystems JNI document
(http://java.sun.com/j2se/1.5.0/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. 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: -Wversion2 or -Wversion3, 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 5.1 Tools
Reference Pages.
3.
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.
4.
The javahjni demo shows an example of how to create a library file. This demo also shows converting between
TNS and IEEE floating point.