java,android,opencv,android-ndk,jni
I've tested your project. To make it build successfully, I had to delete the folder app/src/main/jni and the folder app/src/main/3rdparty and the file opencvlibrary-2.4.9.jar in the folder app/libs/. It looks like you have several opencv libs (thus conflicting with each others) in your project. Hope this helps....
The "bitness" of the native library must be the same as that of the JVM. If you are using a 32-bit JVM, you need a 32-bit native library (no matter if the OS is 32-bit or 64-bit). If you are using a 64-bit JVM, you need a 64-bit native library....
Found a very old 2012 Netbeans post to solve the problem. It is due to a few GCC compiler options missing when making the DLL files. Additional GCC Compiler Option: -Wl,--export-all-symbols -Wl,--add-stdcall-alias Reference: http://forums.netbeans.org/post-130319.html...
I can come up with three different ways to do it. Callback Call a Java method from your JNI code that takes multiple parameters, set a variable somewhere in your Java code, that you can retrieve when returning from the method. JNIEXPORT void JNICALL Java_my_package_name_JNIReturnExample_returnWithJavaCallback(JNIEnv *env, jobject javaThis, jfloat param1,...
android,opencv,camera,jni,android-camera
It seems to Nexus devices fails if you call: mCamera.setPreviewDisplay(mSurfaceHolder); before calling: Camera.Parameters parameters = mCamera.getParameters(); parameters.setPreviewFormat(ImageFormat.NV21); parameters.setPreviewSize(desiredSize.width, desiredSize.height); mCamera.setParameters(parameters); So, if you want your camera works on Nexus, first set preview size and then set surface holder to preview display....
android,c++,bluetooth,android-ndk,jni
First of all, you need to have permission to read this value (which you would need regardless of it being native). Add to AndroidManifest.xml: <uses-permission android:name="android.permission.BLUETOOTH"/> In native jni-land, things are a bit cumbersome. In short, this is what you need: Get class android.bluetooth.BluetoothAdapter Get static method BluetoothAdapter.getDefaultAdapter() Get method...
c++,delphi,jni,c++builder,c++builder-xe7
The .hpp file is malformed. None of the public types defined in the interface section of the .pas file are defined in the .hpp file. In particular, the TToastLength enum is missing. And Toast() is declared as a procedure in the .pas file and thus has no return value, but...
android,c++,qt,jni,qtandroidextras
You should specify the returned JNI type in <...> when calling the method : QAndroidJniObject str = QAndroidJniObject::callStaticObjectMethod<jstring>( "org/.../TestClass" ,"staticMethod"); QString string = str.toString(); Here there is no need to define the signature since your function has no argument....
You appear to be calling GetObjectArrayElement and friends as functions. They are not functions: they are function pointers within env. Call them as (*env)->GetObjectArrayElement(env, ...) ...
You need to pass it exactly the same value you got from GetStringUTFChars(). You're not. You're passing whatever std::string gives you, which isn't necessarily the same thing.
Perhaps confusingly, standard classes like List are not in java.lang or even java.collections but java.util You need Ljava/util/List...
You're creating an Array of "myClass" instead of String stringClass = (*env)->FindClass(env, "java/lang/String"); args = (*env)->NewObjectArray(env, 2, stringClass, NULL); ...
I found a very good example, one of the best on the web I guess, because the author wrote down the paths of each file he uses : Tutorial I still had a library problem so here is how I managed to get all working : Create the java and...
If you have an overloaded method, you need to have the "full" JNI method name. The method name should also include the arguments types (so JNI can distinguish between the overloaded methods) JNIEXPORT jobject JNICALL Java_com_sdl4j_renderer_SDL_1Renderer_SDL_1CreateRenderer__Lcom_sdl4j_window_SDL_1Window_2II (JNIEnv *, jclass, jobject, jint, jint); Technically it's the same method name, then you...
A jint is a primitive type, so if you have included jni.h you can simply return one from the function - there is no need to allocate an Object as you were doing with NewStringUTF() for a String. JNIEXPORT jint JNICALL com_example_myapplication_MainActivity_getintONE(JNIEnv *env, jobject obj) { return 1; //or anything...
java,android,memory-leaks,android-ndk,jni
StrictMode only reports failures to release objects that are explicitly monitored by StrictMode. It doesn't fire because you fail to release a string from JNI. The object allocated at the point in the code indicated by the stack trace needs to be released with an explicit close() call before the...
java,android,c++,android-ndk,jni
Here is the sample code to set the boolean values, follow the same guideline to call the add method of the list. #include <stdio.h> #include <jni.h> #include "com_example_Foo.h" JNIEXPORT void JNICALL Java_com_example_Foo_someFunction (JNIEnv *env, jobject object, jobject returnObject) { jclass clzReturnObject = env->FindClass("com/example/ReturnObject"); jfieldID fieldA = env->GetFieldID(clzReturnObject, "a", "Z"); jfieldID...
Well 100,000 > 16 so you will definitely have trouble. You could try a combination of PushLocalFrame() and PopLocalFrame(), as follows: extern "C" JNIEXPORT jobjectArray JNICALL Java_MessageQueueInterop_receive(JNIEnv * env, jobject this_obj, jclass cls) { int count = 99999; jobjectArray ret = env->NewObjectArray( count, cls, NULL); if( ret ){ for( int...
java,android,android-ndk,jvm,jni
The NDK is used to compile C/C++/asm code into binaries. You can do a lot of things with the NDK, like compiling executables, static prebuilts... but in the end, in the context of an Android application, you obtain one or more .so files (shared object libraries). From Java, you can...
AES_encrypt((const unsigned char *)origin, (unsigned char *)out, &aesKey); AES_encrypt operates on 16-byte blocks. 16 is the block size of AES. Effectively, you truncated your message. AES_decrypt(pout, outout, &aesKey); Here, you only decrypted 16 byes. The remainder of the buffer was back filled with 0. The 0 served as the...
Try: QAndroidJniObject str = QAndroidJniObject::callStaticObjectMethod( "org/.../TestClass" ,"staticMethod" ,"(Ljava/lang/String;)Ljava/lang/String;" ,val.object<jstring>()); I think this function doesn't take template parameter. Than you can do: str.toString() //returns QString And make sure you have imported the Java source files to your android build. For example if your java classes are under android-sources folder add this...
I want to take the bytearray "data" and pass it to the JNI and apply some OpenCV filters so that the preview changes, without returning it. Unfortunately that's not possible. The byte array that is passed to onPreviewFrame() is just a copy of the preview frame, and any changes...
android,c++,android-ndk,jni,jna
JNA provides a stub native library, libjnidispatch.so for a variety of platforms. You can build this library yourself, or extract one of the pre-built binaries from the project's lib/native/<platform>.jar packages. You include libjnidispatch.so in your Android project the way you would any other JNI library. This is required; you cannot...
You need -Djava.library.path=. in the Makefile, and you need to load the library with System.loadLibrary("HelloJNI"); - no lib prefix, no .so suffix. The prefix and suffix are handled by Java - think of it, naming scheme on Windows is different (stupid but fact). And beware of the pitfall that you...
java,garbage-collection,jni,jcuda
Usually, such libraries do not deallocate memory due to garbage collection. Particularly: JCuda does not do this, and has no option or "mode" where this can be done. The reason is quite simple: It does not work. You'll often have a pattern like this: void doSomethingWithJCuda() { CUdeviceptr data =...
What exactly triggers the error message? This error is not unique to my application, so what documentation exists for that error? The error message is right. Something was wrong with my custom installation. Apparently the files lost data when extracted from the executable file. After literally copying in the...
LOCAL_C_INCLUDE := /home/nemesis/adt-bundle-linux-x86_64-20140702/OpenCV-2.4.10-android-sdk/sdk/native/jni/include/opencv2 should be LOCAL_C_INCLUDES := /home/nemesis/adt-bundle-linux-x86_64-20140702/OpenCV-2.4.10-android-sdk/sdk/native/jni/include ie, it is plural and should point to the location from which the following is a relative path: #include <opencv2/core/core.hpp> ...
android-studio,makefile,jni,make
You could use LOCAL_CFLAGS for C/C++ code additional flags or LOCAL_CPPFLAGS for C++ code in Android build system. LOCAL_CFLAGS := -DTEST=1 ...
Yes, the correct way to do this would be to use DirectByteBuffer. It comes with its own drawbacks, though. For example, such Buffer is not backed by array, and access to it from the Java side may be less efficient.
On machine it doesnt work open your dll in dependency walker. Examine the out put for errors, it is possible that you are using debug version of your dll which works fine on machine with visual studio or it maybe c++ redistributable which is missing on target machine
@apangin and @the8472 are both correct, you will not find the java process anywhere, using JNI_CreateJavaVM you are embedding the JVM functionalities in your process. I'll try to give evidence of this through references to the documentation (JNI is sparsely documented but i'll try). From the JNI Specification: Creating the...
android,multithreading,c++11,android-ndk,jni
According to this answer, the destructor of the thread will call std::terminate if the thread is still joinable at time of destruction. If you do not want to join the thread, you can fix this by detaching the thread instead. std::thread t(teste).detach(); ...
The problem is that "gmp" is missing on your system. You have two options: Install the gmp library Compile SoPlex without gmp. For doing this call: make soplex GMP=false A similar issue might come up with the zlib. If this library is not installed on your system. If this is...
c++,qt,jni,qtandroidextras,jbytearray
The signature for a type of jbyteArray is [B. So the method call should be like : jniObject.callMethod<jint>("write","([BI)I",buffer,1000); ...
java,c,multithreading,jni,pthreads
Turns out my suspicion was correct: jobject and jclass references are indeed local, i.e. valid only within the same thread and only until the current native method returns. See http://developer.android.com/training/articles/perf-jni.html#local_and_global_references. My approach of moving the reference-related code to the thread function was correct, except that I need to first convert...
java,android,exception,jni,nosuchmethoderror
java.lang.AssertionError doesn't have the constructor mentioned in the error message. So you can't use ThrowNew(), which relies on that. You'll have to construct the exception yourself and use Throw()....
(The author of JCuda here (not "JCUDA", please)) As mentioned in the forum post linked from the comment: It is not impossible to use structs in CUDA kernels and fill them from JCuda side. It is just very complicated, and rarely beneficial. For the reason of why it is rarely...
With JNI you can: Access Java fields from C. Call Java methods from C. If performance matters to you, you might want to have a data structure for these 4 points, pass a reference to that data structure to C, and in C update the fields of that data structure....
eclipse,sqlite,eclipse-plugin,jni,klocwork
A little patience pays off... I read carefully the error message and it clearly says: Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true -Djava.library.path=".;C:\Program Files (x86)\myLib\win32" So I suddenly recall that I once set a environmental variable like this: _JAVA_OPTIONS = -Djava.net.preferIPv4Stack=true -Djava.library.path=".;C:\Program Files (x86)\myLib\win32" After I changed it to below, things begin to...
I don't think it is possible to call loadLibrary on a .so that is not in the app's apk or on the device (expansions included). What you can do, though, is include your .so libraries inside an expansion file, create a Starter activity that extracts these SO to a system...
java,c++,visual-studio-2010,jni
Converting a comment into an answer, since apparently it helped solve the problem. One way to investigate the problems with MSBuild is by looking at detailed logs. From VS command prompt, cd to directory of the project, then execute command msbuild MyProject.vcxproj /v:d. This will build with detailed verbosity level....
Any Object has finalize() called when the garbage collector has detected that this instance is no longer reachable. So the finalize() may be called due to lose of reachability, not necessary by shutdown().
Have you looked at sys/stat.h to see if there's an actual declaration for stat() or if it's a C preprocessor macro? In the link above, stat will actually be stat64 if __USE_FILE_OFFSET64 is defined. To see if this is your problem, simply change the function name from stat to stat64....
java,dll,jni,unsatisfiedlinkerror,win64
Check for the following. 1) Make sure that there is no typo in the library name . incase of linux it should be some thing like System.load.library("mylib"); then the lib name should be like libmylib.so. 2) You need to add the location of the java library path like -Djava.library.path="path to...
It should look as follows: JNIEXPORT jboolean JNICALL Java_com_test_getData___3D( JNIEnv* pEnv, jclass cls, jdoubleArray dArray ) { jboolean isCopy1; jdouble* srcArrayElems = pEnv->GetDoubleArrayElements(dArray, &isCopy1); jint n = pEnv->GetArrayLength(dArray); jboolean res = false; // here update srcArrayElems values, maybe set res to true if (isCopy1 == JNI_TRUE) { pEnv->ReleaseDoubleArrayElements(dArray, srcArrayElems, JNI_ABORT);...
Since the type of the variable is const char * it suggests that it's a nul terminated string, hence size_t length = strlen(npath); should be enough. Although, your call to bind() is wrong, you shold pass the size of the address structure, for which return bind(sockfd, sun, sizeof(sun)); should be...
java,c,openssl,jni,shared-libraries
BIO_new_mem_buf is in the openssl library. You have to link your library with -lcrypto (lower case L) or with what pkg-config --libs openssl gives you.
-Wl,--export-all-symbols -Wl,--add-stdcall-alias -v adding this solved my problem
Then can I cast like this? Yes. JNI primitive types are machine-dependent. Your second example preserves whatever endian-ness was present in the source, which you haven't specified....
FILE_LIST := $(wildcard $(LOCAL_PATH)/*.cpp) FILE_LIST += $(wildcard $(LOCAL_PATH)/**/*.cpp) FILE_LIST += $(wildcard $(LOCAL_PATH)/**/**/*.cpp) LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) The statements above will get a list of .cpp files in a maximize of three subdirectory. It uses the makefile built-in function for file name operation wildcard. LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard folder/**/*.cpp)) Similarly,...
java,android,android-ndk,jni,leptonica
Following Alex Cohn 's advice I made the following code work: JAVA public byte[] getData() { byte[] buffer = nativeGetData(mNativePix); if (buffer == null) { throw new RuntimeException("native getData failed"); } return buffer; } private static native byte[] nativeGetData(long nativePix); Native jbyteArray Java_com_googlecode_leptonica_android_Pix_nativeGetData( JNIEnv *env, jclass clazz, jlong nativePix) {...
Dalvik never had a GC that moved objects around. We did the necessary prep work, such as explicitly pinning objects, but at the point where development on the copying collector was getting serious (mid-2011) all development efforts shifted to Art. The "global references" list holds all the JNI global references....
Java strings use UTF-16. JNI has no concept of charset encodings other than UTF-8 and UTF-16 (unless you use JNI calls to access Java's Charset class directly, but Java only implements a small subset of charsets, and Windows-1256 is not one of them unless the underlying Java JVM specifically implements...
I just got a response on Facebook which answers my question. Here is the JNI reference: http://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html There you can find following methods: Get<type>Field Routines: NativeType Get<type>Field(JNIEnv *env, jobject obj, jfieldID fieldID); GetStatic<type>Field Routines: NativeType GetStatic<type>Field(JNIEnv *env, jclass clazz, jfieldID fieldID); So I can use GetObjectField() and GetStaticObjectField() which return...
When you use JNA, there is no longer any need to generate C headers nor compile any native code. When using direct mapping, methods declared native are automatically bound to their corresponding methods in the target shared library. JNA uses the method signatures and StdCall tagging interfaces to figure out...
Yes you can, but if the derived class overrides a method, it will introduce a new ID. With a superID calculated for super-class, you will be effectively calling obj.super.method() You can consider it as an analog of Java.lang.Class.getDeclaredMethod() and Java.lang.Class.getDeclaredFields()....
The JNI interface stuff is only needed on the boundary between Java and C. So, even if you have a thousand functions, if you're only calling two of those via JNI directly (with the others being called by those two, or called by other functions that those two call, and...
You can convert your bool to a jboolean then box the jboolean into a Boolean jobject with JNI calls like this: jboolean value = true; jclass booleanClass = env->FindClass("java/lang/Boolean"); jmethodID methodID = env->GetMethodID(booleanClass, "<init>", "(Z)V", false); jobject booleanObject = env->NewObject(booleanClass, methodID, value); ...
As the documentation says, Call<Type>Method calls the method in the object's actual class, while CallNonvirtual<Type>Method calls the method in the class you specify. Consider this Java code: public class A { public void doSomething() { System.out.println("A.doSomething " + this.getClass().getName()); } } public class B extends A { public void doSomething()...
It is strange that you where able to build the code in the first place because on my side I needed to change stuff in configure, configure.ac and Makefile.in to be able for this to compile properly on MacOSX However, assuming that this is not a real issue, I did...
android,android-ndk,jni,jnienv
Caching a JNIEnv* is not a particularly good idea, since you can't use the same JNIEnv* across multiple threads, and might not even be able to use it for multiple native calls on the same thread (see http://android-developers.blogspot.se/2011/11/jni-local-reference-changes-in-ics.html) Writing a function that gets the JNIEnv* and attaches the current thread...
So, sorry for taking that long, but I got the problem resolved. Basically, it is a little typo causing the havoc (at least in your MWE): this->IDgetString = this->JNIEnvironment->GetStaticMethodID(this->javaClass , "getString" , "(()Ljava/lang/String;"); // ^ This parenthesis must be removed. Furthermore, I noticed you did not initialize the object. I...
Environment.DIRECTORY_DCIM is the qualified Java name of the static String defined in the Environment class for the DCIM folder. However, it's isn't the actual value of the String, which is just "DCIM": public static String DIRECTORY_DCIM = "DCIM"; You need to pass the String value, not the Java name of...
Apart from the problem that *mut Any/*const Any are fat pointers, there is also a fact that native JNI functions use double indirection when accessing JNINativeInterface structure: struct JNINativeInterface_; typedef const struct JNINativeInterface_ *JNIEnv; jint (JNICALL *GetVersion)(JNIEnv *env); Here, you can see that JNIEnv is a pointer to JNINativeInterface_ structure...
Your use of DirectByteBuffer will almost certainly fail in spectacular, core-dumping, and unpredictable ways. And its behavior may vary between JVM implementations and operating systems. The problem is that your direct memory must remain valid for the lifetime of the DirectByteBuffer. Since your string is on the stack, it will...
You cannot (and should not) assign a pointer to a normal variable. I really don't know why it allowed for some other normal data types, as you have mentioned. Compiler should have produced same warning equally for all assignment from pointer to other non-pointer data type NULL is a void...
java,android,c,android-ndk,jni
If you pass a data structure to Java, this must be a Java object. You can either create it on the JNI side, or fill in a parameter object passed to JNI by Java. (E.g. Java can create a new byte[4096] and pass it to a JNI function to store...
Isn't this just a mix in the order of the color components? I'm not familiar with any of these functions, but I believe that DIB_RGB_COLORS gives you the components in the “blue, green, red, reserved” order, whereas TYPE_4BYTE_ABGR is expecting the components in the “alpha, blue, green, red” order....
java,jni,64bit,environment-variables
Apparently, the loadLibrary() Documentation has managed to fool me a bit. In case of an UnsatisfiedLinkError it states UnsatisfiedLinkError - if the library does not exist. Therefore, I obviously assumed that loadLibrary() at no point was capable of seeing my specified library. That is, however, not the case as this...
java,android,qt,android-intent,jni
It was stupid mistake. It was wrong method signatures (setAction and setType. Correct, working code: QAndroidJniObject ACTION_GET_CONTENT = QAndroidJniObject::fromString("android.intent.action.GET_CONTENT"); QAndroidJniObject intent("android/content/Intent"); if (ACTION_GET_CONTENT.isValid() && intent.isValid()) { intent.callObjectMethod("setAction", "(Ljava/lang/String;)Landroid/content/Intent;", ACTION_GET_CONTENT.object<jstring>()); intent.callObjectMethod("setType",...
android,android-studio,android-ndk,jni,android-gradle
I think I've got a solution here. It's not as pretty as I would have liked it to be (esp. as it involves creating a temporary file), but I've tested it and it's working as intended. I've written this to use another Application.mk for debug builds, called Application-debug.mk. You can...
JNIEXPORT jint JNICALL Java_com_example_convolution_MainActivity_convolution (JNIEnv *env, jobject obj, jdoubleArray xreal, jdoubleArray ximag, jdoubleArray yreal, jdoubleArray yimag, jdoubleArray outreal, jdoubleArray outimag, jsize n) { jint status = 0; size_t size; size_t i; jdouble *xr, *xi, *yr, *yi, *or, *oi; __android_log_print(ANDROID_LOG_VERBOSE, "log", "start of convolution ", 1); if (SIZE_MAX / sizeof(double) <...
No, the pointer returned from GetMethodID() must not be manually freed. UPDATE: JNI specification explicitly states when a function allocates something, what must be manually released. If a function does not allocate anything that must be freed then the specification usually does not contain such information explicitly written....
In a garbage collected system, there is no such thing as object ownership. There are root object references and object references that are reachable directly or indirectly from the roots. (Weak references are not considered). Both JNI local references and JNI global references are root references. Creating additional references does...
IMO, if you use the default stuff rather than play with class loaders, a reference to any method or field of MyClass from the other classes of your application is enough to prevent unloading of MyClass; just do not bother. What can happen in practice is that a process is...
There are few fixes required in the code: CallIntMethod should be (*env)->CallIntMethod class Test should be public Invocation should be jint age = (*env)->CallIntMethod(env, mod_obj, mid, NULL); Note that you need class name to call a static function but an object to call a method. (cls2 -> person) mid =...
Objects in C always have a positive size, so no sizeof can never lead to 0. C doesn't allow empty struct or union types and also arrays must have a size that is bigger than 0. So there is no correct C type what soever that can return a value...
The JNI side of this code is C, not C++, and C's laxer handling of pointer punning is part of the problem. Your code breaks on these two lines: jstring plainText = (*env)->NewStringUTF(env, "Hello from JNI ! Compiled with ABI 2222 "); return (*env)->NewStringUTF(env, plainText); because NewStringUTF has the signature...
No, there is not built-in function that can do such mapping. But you can do this yourself using if-else or switch structure that is limited to your application. There is one library called "typedef.h" //It is available in C++, I don't know about C It has some functions like type.id()...
Try System.load([full path and filename of ctest]), which works independently from values of LD_LIBRARY_PATH or java.library.path. To ease user configuration I usually implement my own library-search-mechanism, i.e. make it look for libraries in the working directory and on the classpath too. I know ideologically this is somewhat wrong, but works...
java,android,jni,shared-libraries,static-linking
Try to move the declaration of the sndfile module at the top of the file and then edit your native-audio-jni module by adding this: ... LOCAL_SHARED_LIBRARIES := sndfilelib or, alternatively, this: ... LOCAL_STATIC_LIBRARIES := sndfile ...
android,opencv,android-ndk,jni
You should add OpenCV's include directory to the LOCAL_C_INCLUDES otherwise the compiler won't find them LOCAL_C_INCLUDES := $(OPENCVROOT)/sdk/native/jni/include ...
java,c++,exception-handling,jvm,jni
Apparently described behaviour was reported 18 years ago on Windows, please check here. Then with explanation "it looks like addressed" bug was closed during 2002. What you are describing looks very similar to mentioned bug.
It is not required to provide an implementation. You don't even need to compile a header file for your unimplemented methods. However, as is normal, you will get a java.lang.UnsatisfiedLinkError if you call the function....
The problem here was that in : myObject = (*env)->NewObject(env, globalJavaReceiver, sendWaveData); I was trying to create an object from a wrong class function, not from the constructor So then I change this part in: myObject = (*env)->NewObject(env, globalJavaReceiver, nativeReceiverConstructor); where nativeReceiverConstructor is the jmethodID from the class constructor. Then...
EDIT: Sorry I misunderstood your question. You can achieve this by using the other two ways that JNI API provides for creating objects (from docs): jobject NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); jobject NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); NewObjectA Programmers place all arguments that...
..is it possible embed these libs inside the applet? No. Natives should be inside the root path of a separate Jar. There should be separate Jars for OS X, *nix and Windows. Then use Java Web Start to deploy the lot and reference each Jar containing natives in an...
I read lot in order to make it run but, nothing could help, (Somebody said it is the known bug in eclipse) So I just, ported all the code to NetBeans IDE (I am using version 8.0), added all the required classes folders and jars to the Libraries folder added...
java,c++,memory-leaks,jni,native
The Java GC should clean up any objects you allocate. See this answer for more details....
I tried this : extern "C" { void Java_org_cocos2dx_cpp_SceneChanger_nativeCallbackChangeScene(JNIEnv* env, jobject thiz) { Director::getInstance()->replaceScene(MyScene::createScene()); } }; and it replaces the scene successfully. Are you sure Director::getInstance() is a null pointer ? Make sure that you are running on OpenGL thread. Check your error log, look for a line saying call...
When returning reference to New[Type]Array, or other object created in JNI method to Java, should we return result of NewGlobalRef call on created object? Only if you also want to retain that reference for use in future JNI calls without receiving it again as a JNI method parameter. And...
You will need methods "GetStaticFieldID()" and "SetStaticObjectField()". A Java String is just an object. (I assume you know how to create a Java String from a native string). See Accessing Static Fields in the JNI documentation. Edit: sample C (not C++) code (error checking omitted) jstring str; JNIEnv *env; jclass...
You can use the JNI functions for Monitor Operations: jint MonitorEnter(JNIEnv *env, jobject obj); jint MonitorExit(JNIEnv *env, jobject obj); Of course this is C++ so you probably want to put it in a class (RAII): class MonitorLock { JNIEnv *env; jobject obj; public: MonitorLock(JNIEnv *in_env, jobject in_obj) : env(in_env), obj(in_obj)...
You can invoke the JVM from C++, initialize your openCV based components and then run the java code. The basics of the invocation is explaned here, with a sample snippet. For an example to launch a Java component via a static method, you can look at the code at the...