Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

c++ do not support JNi && how to return the array from jni?

843829May 13 2008 — edited May 15 2008
hi,

1.. I have created the Cpp file to implemement the native method but it seems that the native method can not complie rightly , it tells me follows

error C2819: type 'JNIEnv_' does not have an overloaded member 'operator ->'
c:\program files\microsoft visual studio\vc98\include\jni.h(764) : see declaration of 'JNIEnv_'
c:\users\wangyue\desktop\java_gui\beattrack 5.6 - ������_������_������������ 5.7\beattrack.cpp(202) : error C2227: left of '->GetByteArrayRegion' must point to class/struct/union

then I use the c file to paste the same code, it can complie rightly , why? I really need my native method to complie rightly in Cpp file, how to solve it?

2.I want to return a double, for the most simple way, I do the following

#include "RealBeatTrack_BeatTrack.h"

JNIEXPORT jdoubleArray JNICALL Java_playaudio_BeatTrack_BeatTrack
(JNIEnv *env, jobject j, jbyteArray data)
{


jdouble outdata[4]={1,2,3,4};

return (*env)->NewDoubleArray(env, outdata);
}

then in the java code, I difine a array to receive it,

say double mydata[] = new double[4];

mydata= BeatTrack(buffedata);


but the java comlier tells me the Exception in thread "Thread-2" java.lang.OutOfMemoryError: Java heap space?
anyone can help me?


Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2008
Added on May 13 2008
4 comments
217 views