Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2006

Tip: Looking for answers? Try searching our database.

JNI - Getting a double array form Java

Thread view: 
Edsoncv - 17 Aug 2006 15:40 GMT
Hello
I'm trying (without sucess :( ) to get a double array form Java using
JNI.
My function (in C++) calls "CallDoubleMethod" but put trash in my "C"
double array. I'm doing somethig wrong but I don't know what. I check
the values from Java and it is being calculated perfectly, I think the
problem is in the array association (since I'm not a experienced
programmer). Below is my code.

jdouble *jacj = new jdouble[n];
....
get class
get method id
get object and so on...

*jacj = env->CallDoubleMethod(res_gradObj, getdataMetID);

I'm almost sure that the problem is in the last line. Can someone
please help me?
                                    Thanks
Edsoncv - 17 Aug 2006 15:42 GMT
I forgot to say that my function in Java returns a double array.
                     Thanks

> Hello
> I'm trying (without sucess :( ) to get a double array form Java using
[quoted text clipped - 16 lines]
> please help me?
>                                      Thanks
Gordon Beaton - 17 Aug 2006 16:31 GMT
> I'm trying (without sucess :( ) to get a double array form Java
> using JNI.
[...]
> *jacj = env->CallDoubleMethod(res_gradObj, getdataMetID);
>
> I'm almost sure that the problem is in the last line. Can someone
> please help me?

"Array of double" is not a primitive type. Use CallObjectMethod()
instead:

 jdoubleArray jacj = CallObjectMethod(...);

/gordon

Signature

[ don't email me support questions or followups ]
g o r d o n  +  n e w s  @  b a l d e r 1 3 . s e

Edsoncv - 17 Aug 2006 16:48 GMT
Ok, it worked. Thanks again.!! :)

> > I'm trying (without sucess :( ) to get a double array form Java
> > using JNI.
[quoted text clipped - 14 lines]
> [ don't email me support questions or followups ]
> g o r d o n  +  n e w s  @  b a l d e r 1 3 . s e


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.