jni

Android Java Security Provider

Hello, I am trying to install a new Java Security Provider for the javax.net.ssl package on Android. I know how to install a Security Provider on Linux, but am confused about where to place files on the Android system so that they will be built correctly. My Security Provider uses JNI to interface to a C library. In Linux, the follow...

How to catch UnsatisifiedLinkError when using NDK-built library in an Android app?

I have an Android project that contains a class that uses JNI to pull a value from a C function. The C function was built into a library using NDK. The value returned from the C function is in turn used to initialize a variable inside a class when its first loaded. This works fine. However, I also want it to work when the library is miss...

Underlying technique of Android's FaceDetector

I'm implementing a face tracker on Android, and as a literature study, would like to identify the underlying technique of Android's FaceDetector. A brief Google search didn't yield anything informative, so I thought I'd take a look at the code. By looking at the Java source code, FaceDetector.java, there isn't much to be learned: FaceD...

Invalid reference during callback

i have an object that is used for calling callback functions ----- static jobject o; i have assigned the callback function to that object through a pointer, env ----- o=env->NewGlobalRef(callback); The same pointer, env, points towards the function CallVoidMethod( ) that uses JNI to reach to the java code. env->CallVoidMethod(o, meth...

I'm defining a Java class from C with DefineClass() but get UnsatisfiedLinkError

I'm defining a java class from C with the JNI call DefineClass() and then I register the native callbacks for the methods in the class that are native. The class has two static methods, both of which are native. I use RegisterNatives() to register the native functions. Both calls succeed. But when I reference these native methods from m...

How to solve -Invalid reference to a global variable error

i have an object that is used for calling callback functions ----- static jobject o; i have assigned the callback function to that object through a pointer, env ----- o=env->NewGlobalRef(callback); The same pointer, env, points towards the function CallVoidMethod( ) that uses JNI to reach to the java code. env->CallVoidMethod(o, meth...

C++ Overloaded Function Error

Hey everyone, I'm working with JNI on a current project, and am getting a strange error from my C++ code during compilation. I get an error stating: error: overloaded function with no contextual type information This is coming from the "nativegetsupportedciphersuites" line in the following array, which is mapping java functions with ...

Android JNI System.loadLibrary not needed?

Hey everyone, I need your help to add some insight into JNI on Android. I've been looking at the /libcore/x-net package in Android and notice that Apache Harmony is the default provider for SSL functionality (using OpenSSL). Everywhere I've found on the internet says that when you use JNI in Android you must load the native code by us...

How do I access return value of a Java method returning java.lang.String from C++ in JNI?

I am trying to pass back a string from a Java method called from C++. I am not able to find out what JNI function should I call to access the method and be returned a jstring value. My code follows: C++ part main() { jclass cls; jmethodID mid; jstring rv; /** ... omitted code ... */ cls = env->FindClass("ClassifierW...

JNI_ENOMEM from JNI_CreateJavaVM when calling dll that uses JNI from VB6

I work on a legacy system that has a VB6 app that needs to call Java code. The solution we use is to have the VB app call a C++ dll that uses JNI to call the Java code. A bit funky, but it's actually worked pretty well. However, I'm moving to a new dev box, and I've just run into a serious problem with this. The built VB app works fi...

Updated DLL causes JNI to throw "Exception c0000005"

Here's my problem. I have a third part DLL (to which I do not have the source) that I have to use JNI to talk to. The people that supply this DLL are not a Java-house. I discovered a bug in their DLL, so wrote some C++ which exercised their DLL, exposed the bug and sent it to them for a fix. I finally got an updated DLL back from t...

Problem with JNIRegistry

I am using JNI Registry API to access Windows registry. Here is my code: import com.ice.jni.registry.Registry; import com.ice.jni.registry.RegistryException; import com.ice.jni.registry.RegistryKey; import com.ice.jni.registry.RegistryValue; public class JNIRegistryExample { public static void main(String[] args) { Registr...

Two way object passing with jni4net (was: Ignore Missing Class(es))

I am using jni4net to access Java code from within a C# application, and vice-versa. jni4net uses reflection to generate JNI code proxies, so obviously one of the limitations is that your Java and C# code have to compile in order to build proxies. Unfortunately this can result in a catch-22 problem. Consider: C# class X uses Java class...

Undefined Reference in JNI

I am declaring a JObject NewObjectV. jobject NewObjectV (JNIEnv *env, jclass cls, jmethodID methodId, WIMAX_API_DEVICE_ID_P pDeviceId); But am getting the following error undefined reference to ' android :: NewObjectV(_JNIEnv *, _jclass *, _jmethodID *, _WIMAX_API_DEVICE_ID_P *). What should be the code to remove this error? My comp...

create a JNI int Array and add some values

I have read some posts here about arrays in JNI but since I'm not familiar with JNI at all I still don't know how to create a int array and add some values. I have two int values and I want to put them into a int array to return that array (at the end of the call). I think it's something very simple and unfortunately I couldn't do it ye...

Pro*C/C -->Java --->pro*c using JNI

I have some Pro*C code and some java method. end user will invoke Pro*C/C binaries on linux/solaris/aix, it will make call to Java method post execution of java method, call should be back to C/Pro*c calling function Any example/POC. PS : there are many sample to call Java--->C but not much reverse. No C++ please ...

Passing a byte[] in Java to a function in C through JNI: how to use jarraybyte

Hi there, This is the first time that I use the JNI and also the first time that I have to write some lines in C. What I am trying to do is very simple. I'm just trying to switch the endiannes of a byte[] using a C routine. In java it is done like this: public void switchEndianness(byte[] array){ byte byte1; byte by...

What is the purpose of _GLOBAL__I_?

Hi, I have two functions declared as following, using extern "C" aming to avoid name mangling. #ifdef __cplusplus extern "C" { #endif JNIEXPORT jobject JNICALL Java_com_trident_tv_si_SIManagerImpl_nGetServiceDetails (JNIEnv *, jobject, jint); JNIEXPORT jobject JNICALL Java_com_trident_tv_si_SIManagerImpl_nGetServiceCurrentEvent (...

How do you specify to display a diamond in a NSMenuItem (minimized window indicator)?

I'm creating a JNI to display an application wide menu bar instead of the JFrame specific one. This allows me to keep a menubar displayed even when no JFrames are present. I've hit a small snag, in my window menu I can't figure out how to display a diamond for the windows that are minimized. As far as I can tell in the standard API there...

Callback to Java method from c++

Here is my situation and it's a bit complicated, but it has to be this way. I'm implementing a program from Java that open an application by using JNative. The application is written in C++. But when the application is finished I want it to callback to Java to let Java knows that the run is finished. Can I do that and how? I know I shoul...