JNI question!
-
Chua Wen Ching
Hi,
I had some doubts on the Java Native Interface thing. I am very confuse as i never code JNI before. Here are my questions.
In you java code:
System.loadLibrary("Sample1");
Does it means i must already have Sample1.dll inside my windows xp operating system registered?
As i seen many tutorial, create a java file, compile it, use javah -jni to create header files (i fail to do this, i see this error:
C:\JNITest\test>javah -jni test
Error: Class test could not be found.)I am quite confurse.
Please help! Hope you can send me your comments to my email! Thanks.
Posted: 2004-05-23 14:22:25.717307 #
-
Binod Kumar Suman
Step 1. Complie your java source code
like C:\JNITest\test>javac test.java
then you check in your test folder,
one class i.e. test.class is created.Step 2. C:\JNITest\test>javah -jni test
execute this command then you check your test folder, you will get test.h file there.Setp 3.C:\JNITest\test>cl -Ic:\jdk\include -Ic:\jdk\include\win32 -LD Sample1.c -FeSample1.dll
Then you will get Sample1.dll in your folder.
Step 4. Run the Java code
C:\JNITest\test>java testPosted: 2006-06-26 11:39:24.526037 #