java-native-interface

java JNI error java.lang.UnsatisfiedLinkError:

 ̄綄美尐妖づ 提交于 2020-01-03 13:39:37
问题 java -Djava.library.path=. TestJNI >>>> Exception in thread "main" java.lang.UnsatisfiedLinkError: TestJNI.calibrate([D[DII)[D at TestJNI.calibrate(Native Method) at TestJNI.main(TestJNI.java:61) I know the library is getting loaded otherwise the error says cant find calibrate library. what does the above error mean? EDIT this is my implementation- JNIEXPORT jdoubleArray JNICALL Java_TestJNI_cailbrate (JNIEnv * env, jobject jobj, jdoubleArray rtt, jdoubleArray distance ,jint activecount,jint

NetBeans Development 7 - Windows 7 64-bit … JNI native calls … a how to guide

感情迁移 提交于 2020-01-03 11:57:29
问题 I provide this for you to hopefully save you some time and pain. As part of my experience in getting to know NB Development v7 on my Windows 64-bit workstation I found another frustrating adventure in trying to get the JNI (Java Native Interface) abilities up and working in my project. As such, I am including a brief summary of steps required (as all the documentation I found was completely incorrect for these versions of Windows and NetBeans on how to do JNI). It took a couple of days of

Passing an Array from JNI to Java

社会主义新天地 提交于 2020-01-03 06:04:31
问题 I want to access an array from JNI to Java (By creation of shared library libtest.so file) I'm doing it as below: JNI Code (C) int size = 5; /* Array Size */ char sample_arr[size] = {1, 2, 3, 4, 5}; /* Array to be accessed in Java */ jbyteArray result_arr = (*env)->NewByteArray(env, size); (*env)->SetByteArrayRegion(env, result_arr, 0, size, sample_arr); jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "(I)V"); (*env)->CallVoidMethod(env, obj, mid, get_event); I believe that jbyte in

android load library failed

荒凉一梦 提交于 2020-01-03 04:25:08
问题 When I use System.loadLibrary() to load my so file, rarely, it fails and the Logcat says Cannot load library: reloc_library[1286]: 121 cannot locate '__cxa_atexit' java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1285]: 169 cannot locate '__cxa_atexit'... at java.lang.Runtime.loadLibrary(Runtime.java:370) at java.lang.System.loadLibrary(System.java:535) After searching the Internet, I don't find any infomation about cannot locate '__cxa_atexit' (especially the key word __cxa

Access the current android activity

时光毁灭记忆、已成空白 提交于 2020-01-03 04:09:06
问题 How can I access the current Android activity class? I am using the necessitas framework (QT in Android). Basically, using the Android NDK an activity calls a QT application (.so). All runs fine. Now I am working on some bindings to access the GPS from the QT application. From some java examples that access the GPS I saw that the most vital part is to allow access to the GPS service: LocationManager lm; lm = (LocationManager) getSystemService(LOCATION_SERVICE); Here getSystemService is a

Execute a command with superuser permission in JNI method in Android

Deadly 提交于 2020-01-03 03:28:43
问题 In Java, I can have something like this: Process p = Runtime.getRuntime().exec("su"); DataOutputStream pOut = new DataOutputStream(p.getOutputStream()); pOut.writeBytes("find / -perm -2000 -o -perm -4000\n"); pOut.writeBytes("ps\n"); pOut.writeBytes("ls\n"); pOut.writeBytes("exit\n"); pOut.flush(); p.waitFor(); I know that to execute the find command in JNI method, we can use system or popen function. But I don't know how to execute it with su privilege? PS: Since the system function forks a

running dll method Javafx

孤人 提交于 2020-01-03 02:54:18
问题 I have C program (Dll) which I can call from Java using JNI. I want to use Javafx for the interface so I made a java class to call the dll. I am able to load the dll but I cannot call the method. The error message it gives me is java.lang.UnsatisfiedLinkError: mark1.Small_test.tester(DDDLjava/lang/String;Ljava/lang/String;Ljava/lang/String;DDD)[D java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl

JNI: Callback from JVM to C++ fails to run

和自甴很熟 提交于 2020-01-03 02:38:45
问题 I start JVM from C++ program. C++ code: JNIEXPORT jobject JNICALL com_javelin_JavelinMarketData_callBackIntoNative(JNIEnv* env, jobject obj, jlong ptr) { std::cout << "com_javelin_JavelinMarketData_callBackIntoNative called" << std::endl; } int main() { JavaVM* jvm; JNIEnv* env; ... JNI_CreateJavaVM(&jvm, (void **)&env, &args); jmethodID mainMethod = env->GetStaticMethodID(helloWorldClass, "main", "([Ljava/lang/String;)V"); env->CallStaticVoidMethod(helloWorldClass, mainMethod, ...); } then I

Android NDK. No implementation found for native Lcom

被刻印的时光 ゝ 提交于 2020-01-02 16:39:19
问题 After all I've managed to "prepare" my eclipse for NDK (atleast i think so), it doesnt argue at c code anymore, but now I'm getting "No implementation found for native Lcom" anytime i execute any native code.. It happens on NDK's samples too.. My .java ... private native float pi(); static { System.loadLibrary("shit"); } ... System.out.println(pi()); ... My .cpp #include <jni.h> jfloat Java_com_example_shit_MainActivity_pi(JNIEnv * env, jobject obj) { return 3.1415; } My .mk LOCAL_PATH := $

android cannot find corresponding jni function

本秂侑毒 提交于 2020-01-02 15:37:27
问题 I've followed here and I've added the .so files to my android project. Loaded the library and the project runs. Now I want to use a function of the library. I tried like this in my MainActivity : public final static native int crypto_aead_chacha20poly1305_encrypt(byte[] jarg1, int[] jarg2, byte[] jarg3, int jarg4, byte[] jarg5, int jarg6, byte[] jarg7, byte[] jarg8, byte[] jarg9); Android gives me that he cannot find the corresponding JNI function. The so files are in jniLibs in the right