java-native-interface

Qt does not compile callStaticObjectMethod()

≯℡__Kan透↙ 提交于 2020-01-05 13:14:29
问题 I wrote the following code from this question and it was compiled and worked perfectly: QAndroidJniObject str = QAndroidJniObject::callStaticObjectMethod<jstring>( "org/.../TestClass" ,"staticMethod"); Now I have changed the java method and it needs an input parameter of type string. The Java code : public class TestClass{ public string str; public TestClass() { str = "Test From Java"; } public static String staticMethod(String str) { return "Test From Java, "+str; } } But adding the method

can we access “sysfs entry” in our android application directly?

情到浓时终转凉″ 提交于 2020-01-05 06:54:09
问题 I know that we are using jni as an interface with driver which allows android application framework to communicate with device driver. But i don't know exact reason that why we can't access those sysfs entries in our application directly? Please explain in detail. Thank you in advance. 回答1: Cannot access sysfs from application layer. I was trying to perform write on a sysfs file but failed. Have to necessarily go through android middleware framework and/or HAL layer. These services could be

Static libraries and JNI

那年仲夏 提交于 2020-01-05 06:53:14
问题 I have created a header file and a corresponding .c file full of functions I would like to use with a java program. I created a JNI header file using javah. I'm using gcc to compile my header file. How can I link my regular c object file with my JNI static library to get a static library that utilizes my C library? I'm using gcc to compile. Here's an example of what I'm asking: lib.h lib.c JNITest.h JNITest.c (uses lib.h functions) 回答1: You might try looking at this http://java.sun.com

Native library in Tomcat UnsatisfiedLinkError + Windows + eclipse

和自甴很熟 提交于 2020-01-05 06:29:26
问题 This question might have been asked earlier on SO, and please be assured I did check all the available solutions. Was still unable to get it to run My problem is exactly as described in this post Shared native library in Tomcat UnsatisfiedLinkError Standalone Java application is running perfectly well. However with Tomcat(9) it fails to run and throws java.lang.UnsatisfiedLinkError: third_party.org.chokkan.crfsuite.crfsuiteJNI.swig_module_init()V at third_party.org.chokkan.crfsuite

Native library in Tomcat UnsatisfiedLinkError + Windows + eclipse

混江龙づ霸主 提交于 2020-01-05 06:27:09
问题 This question might have been asked earlier on SO, and please be assured I did check all the available solutions. Was still unable to get it to run My problem is exactly as described in this post Shared native library in Tomcat UnsatisfiedLinkError Standalone Java application is running perfectly well. However with Tomcat(9) it fails to run and throws java.lang.UnsatisfiedLinkError: third_party.org.chokkan.crfsuite.crfsuiteJNI.swig_module_init()V at third_party.org.chokkan.crfsuite

include .h file into java file in android using jni as source folder of .h file?

泄露秘密 提交于 2020-01-05 04:40:13
问题 void ProcedureParams_Initialize(ProcedureParams* pVal); flag ProcedureParams_IsConstraintValid(const ProcedureParams* val, int* pErrCode); flag ProcedureParams_XER_Encode(const ProcedureParams* val, ByteStream* pByteStrm, int* pErrCode, flag bCheckConstraints); flag ProcedureParams_XER_Decode(ProcedureParams* pVal, ByteStream* pByteStrm, int* pErrCode); flag ProcedureParams_BER_Encode(const ProcedureParams* val, ByteStream* pByteStrm, int* pErrCode, flag bCheckConstraints); flag

Compile for JNI in windows 7

纵然是瞬间 提交于 2020-01-05 04:13:32
问题 I am trying to compile an open source project called jbliss as a DLL under windows 7, so that I can use it with JNI in Java. Everything works fine in Linux using the makefile already provided in the package. My first search pointed me to cygwin, and then I followed several suggestions, like this one, which basically tells me to use: gcc-3 -D __int64="long long" -mno-cygwin -Wl,--add-stdcall-alias -I"<JAVA_HOME>\include" -I"<JAVA_HOME>\include\win32" -shared -o jbliss.dll *.cc This brings me

JNI Call java method from c program

守給你的承諾、 提交于 2020-01-05 02:53:31
问题 I need to call java method from c program. i have tried below code to call the java method through Java native interface but facing issues while compilation. i m new to C and have experience in java. so, i m not able to think myself what is happening while creating JVM. Below is the code. CTest.c #include <stdio.h> #include <jni.h> JNIEnv* create_vm() { JavaVM* jvm; JNIEnv* env; JavaVMInitArgs args; JavaVMOption options[1]; args.version = JNI_VERSION_1_6; args.nOptions = 1; options[0]

How to call a Java function via JNI from a signal handler function in Android

萝らか妹 提交于 2020-01-05 01:07:26
问题 My objective is to send a signal from kernel to a Android service running in the userspace.On receiving this signal, the service should make an IOCTL call back to the kernel. After it gets data from the kernel through this ioctl call,it has to display to the user. For this, i call a native method from my Java Service, which registers the sigaction structure, which includes the handler function for this signal. This handler function will make the IOCTL call and call a Java Function to pass the

Calling C++ from Java, but Java loads the wrong Glibc version

余生长醉 提交于 2020-01-04 23:01:17
问题 I am trying to call a C++ library from java side and have written necessary jni code. However, when my java code tries to load my C++ library via System.loadLibrary , it complains the following error: Exception in thread "main" java.lang.UnsatisfiedLinkError: libmylib.so: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by libmylib.so) I later found that it is because I have two different GLIBC versions on my system, and the default one is the older one, while libmylib