The java\bin directory includes a file named jni.zip, which contains simple native method examples for Java 1.x. This section provides an example of how to write native methods for NJVM. However, this is not a comprehensive tutorial on writing native methods.
NOTE: When writing graphical Java applications to run on NetWare, we recommend using the Swing classes from Sun Microsystems.
These tools and build environment are for the examples in jni.zip. Other compilers (like Metroworks) and build tools can be used.
The following table provides descriptions of the Java files:
After you unpack the package, complete the following:
Configure the following parameters in the makefile:
Enter the following at a Windows command prompt:
nmake
To clean the build, enter the following at a Windows command prompt:
nmake clean
After you build the example and map your server volume sys: (for example, to drive G:), complete the following steps to install JNI:
Check to see if g:\java\classes exists as a directory. If not, enter
mkdir g:\java\classes
Copy the NLM to g:\java\bin by entering
copy nwnative.nlm g:\java\bin
Copy the classes to g:\java\classes, then at the command prompt in Windows, enter
copy *.class g:\java\classes
If your CLASSPATH variable is correct, you can run JNI by entering the following at the command prompt:
java NWTest
To unload JNI, enter java -exit at the system console.
This section contains notes and examples that might be helpful with the JNI process:
Option SYNCHRONIZE
With the synchronize option, you can initialize any global information your NLM program might contain in the main() function as long as you call the following function after initialization has completed:
void SynchronizeStart();
For example:
main()
{
/* Do global initialization */
SynchronizeStart(); /*MUST BE CALLED */
ExitThread (TSR_THREAD,0); /* MUST BE CALLED*/
}
If you choose to not use a synchronized startup for your NLM program, you must limit your main() function to the following:
main ()
{
ExitThread (TSR_THREAD,0);
}
Using these macros gives you free resource tracking. This also lets the memory used by your NLM program use virtual memory in NetWare 6.5. In some instances, you might prefer memory returned from malloc, such as buffers used for callbacks or ECBs.
NOTE: If you attempt to resolve this issue by linking the correct library, the makefile will link the wrong prelude.obj.
To prevent these warnings, do one of the following makefile options:
Option NoDefaultLibs
LIBPath $(WATCOM)\lib386;$(WATCOM)\lib386\netware;
LIBFile $(WATCOM)\lib386\plbx3s.lib
Optimized flags are
/zp=1 /ri /ei /5s /or /ot /w3 /s /zq /ez
Debug flags are
/zp=1 /ri /ei /d2 /od /3s /w1 /s /zq /ez
IMPORTANT: /ri and /ei are critical for building native method NLM programs.