• Post Reply Bookmark Topic Watch Topic
  • New Topic

Character arrays w/ JNI  RSS feed

Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok what I am trying to do is build a C array of character pointers. Much like char *argv[] that you see in C programs.
This is how I am attempting to approach it:
Java_ImageRead_imageRead(JNIEnv *env, jobject obj, jcharArray floppy, jcharArray image)
char *argv[4];
jchar* flop = env->GetCharArrayElements(floppy, 0);
jchar* img = env->GetCharArrayElements(image, 0);
argv[2] = (char*)flop;
argv[3] = (char*)img;
char* testFlop = argv[2];
char* testImg = argv[3];
printf("\nflop is %s\n", flop);
printf("\nimg is %s\n", img);
printf("\ntestFlop is %s\n", testFlop);
printf("\ntestImg is %s\n", testImg);
env->ReleaseCharArrayElements(floppy, flop, 0);
env->ReleaseCharArrayElements(image, img, 0);
return 1;
my output is:
flop is a
img is c
testFlop is a
testImg is c
Ok, so then I iterated through the char* doing a
printf("%s", img+i); where i started at 0 and finished at the length of img. I got exactly what I expected, the entire string/ char array c:/flop.img
I believe I see what is happening but, I need entire string to be assigned to argv so I can pass that to another method.
Any ideas? Thanks.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!