1) Get yourself a copy of
The Java native Interface
Publisher: Addison Wesley
Authors: Sheng Liang
ISBN 0-201-32577-2
303 Pages
2) Why are you using char[] ? This is not portable or unicode compatible . All Java
String
are unicode characters by default. You need to pass just java.lang.String
and use JNI functions to convert to native C/C++string and vice versa
--
Peter Pilgrim
Welcome to the "Me Too" generation.
---------------------------------------- Message History
----------------------------------------
From: [EMAIL PROTECTED] on 21/07/2000 02:17
To: [EMAIL PROTECTED]
cc:
Subject: How to pass string between java and c?
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);
...........
}
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]