?
Solved

return object with stringArray as its content from JNI

Posted on 2004-09-14
7
Medium Priority
?
193 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

801 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