Hello everyone!
I have a problem in passing string between java and c.
I will use native method writted in c ,and pass some string to c for processing.
The class to load liabrary is following:
public class loadIO
{
public native boolean write(char[] path, char[] name,char[] value);
static{
System.loadLibrary("IO");
}
}
I compile this class successfully and use javah to make a .h file for c.
In the .c file ,the method declaration is follwing:
JNIEXPORT jboolean JNICALL Java_IO_write
(JNIEnv *env, jobject obj, jcharArray path, jcharArray name, jcharArray value)
{
jchar * buf;
env->GetCharArrayRegion(path, 0, 100, buf);
...........
}
The liabrary is compiled sucsuccessfully,but when I run java program ,the following
error message is printed:
java.lang.UnsatisfiedLinkError: write
at com.JiaTeng.adsl.adslCfgGui.ConfigDlg.<init>(ConfigDlg.java:124)
at com.JiaTeng.adsl.adslCfgGui.ConfigDlg.<init>(ConfigDlg.java:130)
at com.JiaTeng.adsl.adslCfgGui.ConfigDlg.main(ConfigDlg.java:161)
at symantec.tools.debug.MainThread.run(Agent.java:48)
Distinctly,the error occured in passing string between java and c.
But I don't know what is wrong in it,because native is difficult to debug.
Who anyone can tell me where the bug is ?
If I use String instead of char[],the corresponding type in c is jarray.
How can I process jarray type in c?
Thank you very much!
Boris
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]