The function definition itself specifies the JNIEXPORT keyword so that it is known as a dll export and it is not using anything really from the header file . What is the need to include it?
I experimented creating a C++ file without including it, created a dll out of it and calling it from java. But I get this exception below. Why?
Exception in thread "main" java.lang.UnsatisfiedLinkError: ObjectArrayTest.initInt2DArray(I)[[I
This line in my program seems to cause the problem:
jclass intArrCls = env-%26gt;FindClass("[I");
JNI question: What is the need to include the header file generated by javah command in the C program?
Based on the question, I'm assuming that you're not a C/C++ developer.
When constructing a DLL, you need a header file to interface to it.
Since you're developing in Java, think of a header file as an IDL file. An IDL file contains the complete interface definitions (like a header file in C). The corresponding Java class contains *both* the interface definitions and the implementations (like a C file).
C/C++ compilers use these header files to get "advance notification" of what to expect in the code. See this page http://en.wikipedia.org/wiki/Header_file for a complete explanation of the need to include header files.
aster
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment