Solved

return object with stringArray as its content from JNI

Posted on 2004-09-14
7
186 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now