Hi! I'm having trouble grasping the JNI concept: I have a method in an .java file that sends a String array to my native code,which is written in C. I'm trying to manipulate this String array (just for educational purposes) and return the manipulated String array back to my Java code. Can anyone teach me the right way to access the elements in the String in C? And what do I have to do to manipulate the array in C. I'm familiar with process of making a header file from Java, etc. It's just the C part that I'm struggling with..
OKB, Please change your name to be compliant with JavaRanch's naming policy. Your displayed name should be 2 separate names with more than 1 letter each. We really would prefer that you use your REAL name. Thanks, Cindy PS: I am no C person - so I will leave this for others to reply to.
"JavaRanch, where the deer and the Certified play" - David O'Meara
If you are just starting with JNI it might be better to deal with passing in a primative type and returning a primative type first, before dealing with Strings. As strings are an Object there is some complicated casts and object gets required which can be difficult. And also C uses ASCII/ANSI while java uses Unicode so there are quite a few 'gotchas'. Note also that while C strings are mutable, java strings are not so when you manipulate the string in C you will not be changing the original in java, so will need to pass back the result. There is quite a good java tutorial on the sun site for JNI and I would suggest that as a good start if you still want to play with Strings ;-)
The Eagle sneers at the Peacock<p>Systems Administrator<br />OrderWare Solutions Ltd<br /><a href="http://www.orderware.net" target="_blank" rel="nofollow">http://www.orderware.net</a>
grapes are vegan food pellets. Eat this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss