This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Converting JString array into char*[]
- To: java at gcc dot gnu dot org
- Subject: Converting JString array into char*[]
- From: Bryan Ha <kfh1_99 at yahoo dot com>
- Date: Fri, 17 Aug 2001 14:41:49 +0100 (BST)
Hello,
I am new to CNI and would appreciate if anybody could
help me out with this problem.
I am trying to pass down a String array from Java code
to the native code like this:
My aim is to convert String[] into char*[] which can
be used by the system call execve. Does this work ?
And is this the preferred way ?
Java part -Hello.java
public native int process(String[] arguments,String[]
env)
Native part
jint Hello::process(java::lang::String[] arguments,
java::lang::String[] environ)
char* args[arguments.length];
char* envp[environ.length];
int i=0;
int l1;
int l2;
for (i=0;i<arguments.length;i++) {
jstring arg=arguments[i];
jstring env=environ[i];
l1=JvGetStringUTFLength(arg);
l2=JvGetStringUFTLength(env);
JvGetStringUTFRegion(arg,0,l1,args[i]);
JvGetStringUTFRegion(env,0,l1,envp[i]);
}
execve(cmd,args,envp);
Any comments are much appreciated.
Many thanks,
Bryan
____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie