Gosh, as i mentioned earlier, i dont know anything about JNI, and even now, after 1 day playing around with the code, i am still so confuse with what is JNI and what is the main purpose of using this (even though i have the e-book on my hand). Well, i admit this, i am not very interested to do study on this, haha.
Anyway, back to the topic, even though i might not understand what is the JNI, what is Native Library, now, i need to learn how to compile the C/C++ code to generate a DLL file for the Java code program usage.
Ignore how the code look like, just imagine in your directory, you have two different pieces of codes, one is written in Java and another one is written, um let's say in C++.
1. Open the command prompt, access to the folder, then type
'javah -jni sourceCode'
2. Then you will see there is a sourceCode.h file created in your directory
3. The next step is to create the native library or the DLL file (Windows)
'cl - Ic:\programfiles\java\jdk1.6.0_16\include - Ic:\programfiles\java\jdk1.6.0_16\include\win32
-MD -LD sourceCode.c - FesourceCode.dll'
(*in one line)
4. Then you will see there is a DLL file generated in the directory.
5. Type 'java sourceCode'
6. Then the output will be displayed on the screen.
The purpose of writing this blog, as i mentioned in last post, in just a place for me to keep steps down, just in case one day in the future i need this again.
Sigh*, getting older and older...
No comments:
Post a Comment