Solved

return object with stringArray as its content from JNI

Posted on 2004-09-14
7
191 Views
Last Modified: 2008-02-01
Hi,

i have a class something like,

public class temp {
    int x;
    String str;
    String[] strArray;
}

now i want to return this object completely from JNI. So, return object should have int,string and stringArray.
how can i do this ?
code sample will be highly appreciated.

thanks,
Hitesh
0
Comment
Question by:hitu_shah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12063196
Write a method that returns a type of 'temp'. You need to set create it and set its fields with SetIntField and SetObjectField. There's an example here:

http://java.sun.com/docs/books/jni/html/fldmeth.html
0
 

Author Comment

by:hitu_shah
ID: 12066885
Hi CEHJ,

if you give me some type of example for the above class it will be great.
I read the link you sent me but it doesn't mention how can i fill array of string.

thanks in advance,
Hitesh
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12067110
There are some examples with arrays here:

http://java.sun.com/docs/books/jni/html/objtypes.html
0
 

Author Comment

by:hitu_shah
ID: 12068962
Hi CEHJ,

i have seen this example. But it returns object array. What i am saying is that i can fill the array of string from JNI, but how can i assign this filled object to the strArray[] parameter in above class.

again, if you give some sample code it will be excellent.

thanks,
Hitesh
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 12072671
Unfortunately not much time now as i have to go out

>>but how can i assign this filled object to the strArray[] parameter in above class.

You need to call SetObjectField on it
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question