Solved

return object with stringArray as its content from JNI

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to implement Singleton Design Pattern in Java.

728 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