Questions tagged [java-native-interface]

The Java Native Interface (JNI) gives both the ability for JVM implementations to run system native code and the ability for native code to run Java code (by creating new JVM instances). The most common target languages for JNI are C and C++, for which at least the Sun/Oracle JDK implementations provide helper commands (javap - for code disassembly, javah for c code generation).

The JNI defines a standard naming and invocation convention which allows the Java virtual machine to locate and invoke native methods.

In fact, JNI is built into the Java virtual machine, allowing the Java virtual machine to invoke local system calls which perform input and output, graphics, networking, and threading operations on the host operating system.

The naming and invocation convention has been standardized by the JNI specification.

References:

9715 questions
4
votes
2 answers

How to use JNI to call JAVA method from C

I want to use JNI (Java Native Interface) to call a specific java setter method, passing a short[] buffer into it as a parameter. Java method implimentation looks as follows: public void setPcmLeft(short[] data) { pcm_l = data; } From inside my C…
Sabobin
  • 4,256
  • 4
  • 27
  • 33
4
votes
1 answer

UnsatisfiedLinkError: Native method not found - Android

I am developing an android app using C++ code. Trying to use JNI but failed. The code in myFirstApp.cpp JNIEXPORT jint JNICALL Java_com_example_myfirstapp_CreateApp_findMarkersNative( JNIEnv* env, jobject, jlong addrRgba) { //clock_t…
omarsafwany
  • 3,695
  • 8
  • 44
  • 75
4
votes
1 answer

How to obtain Java "object" address in Java Native Interface

Is it possible to get the address of a Java object in a JNI method? Or by any other method. If it is not possible to get real address of an object, then is there a way to determine the memory layout of a data structure? (This is just an example,…
dawnstar
  • 507
  • 5
  • 10
4
votes
1 answer

UnityPlayerActivity not getting onCreate() log

I am trying to extend UnityPlayerActivity with the help of docs.unity3d. I have a simple jar file with MainActivity class and also included the file classes.jar to the libs folder. My class file has following code. package…
Nick
  • 1,035
  • 1
  • 11
  • 18
4
votes
2 answers

c int array to java int array using jni

I have a function something similar to, int * print(int count) { int * myarray; int i=0; myarray = (int *)(malloc(sizeof(int))*count); for(i=0;i
Naruto
  • 245
  • 1
  • 6
  • 13
4
votes
1 answer

Same native library loaded by different class loader

Please consider the following scenario: I have two java classes, loaded using different system class loaders. I have a native library that has a queue implemented. Both the classes will load the same library, and add elements to the queue. Is it…
Reji
  • 3,426
  • 2
  • 21
  • 25
4
votes
1 answer

Get all instance of JavaVM* in the current process?

This is only specific to Windows. Does JNI provide any API that returns all instance of JavaVM* of the calling process? Consider the following scenario, a C++ dll is injected into a java.exe process. Now the question is, how can the C++ dll locate…
ains
  • 1,436
  • 4
  • 18
  • 33
4
votes
0 answers

Android native debug, ndk-gdb libraries not found

I have an Android application with JNI (and SWIG). The application runs fine and I can debug the java and the native code, but I keep having warnings from gdb that I have no idea where they come from, I stripped the code down to a very simple…
Pedru
  • 1,430
  • 1
  • 14
  • 32
4
votes
2 answers

No Implementation found for native UnsatisfiedLinkError Exception Android JNI

I'm trying to implement LAME for an Android App, but I keep getting the error: W/dalvikvm(2472): No implementation found for native Lcom/example/android/audio/util/LameWrapper;.init (IIIII)V java.lang.UnsatisfiedLinkError: init at…
ShannonS
  • 354
  • 1
  • 4
  • 13
4
votes
1 answer

Is needed to release jboolean using JNI?

I 'm trying to call a Static method from C++ to Java. But I get the following error: D/cocos2d-x debug info(29160): isInternetConnected Done, value is: 1 A/libc(29160): @@@ ABORTING: INVALID HEAP ADDRESS IN dlfree A/libc(29160): Fatal signal 11…
vgonisanz
  • 11,831
  • 13
  • 78
  • 130
4
votes
1 answer

Using pjsip with android

I successfully installed and builded the pjsip library and pjsua for android, I ran pjsua on my device and it worked, however I'm still lost on how to use the methods of this library. I already took a look on the CSipSimple app and I noticed that…
onizukaek
  • 1,082
  • 1
  • 14
  • 38
4
votes
1 answer

UnsatisfiedlinkError : undefined symbol _ZN5boost6system16generic_categoryEv in java (JNI)

I have created an .so file in which I am not at all using the boost library (Of course earlier I used it), but later I switched to pthreads and removed all the header files and boost .so file linking from the makefile. The java files are getting…
Chaitanya
  • 3,399
  • 6
  • 29
  • 47
4
votes
1 answer

Get object from an object with JNI in C

public class Student { private People people; private Result result; private int amount; } Here is the sample of the class in Java; in C, I tried to get the "people" in "Student", but I failed. However, I am able to get int type "amount"…
user1151874
  • 269
  • 3
  • 5
  • 15
4
votes
5 answers

Sending a keyboard event from java to any application (on-screen-keyboard)

I am working on developing an on-screen keyboard with java. This keyboard has a JComponent for every possible key. When a mouse down is detected on the button, I want to send a specific keyboard code to the application currently on focus. The…
Mario Ortegón
  • 18,670
  • 17
  • 71
  • 81
4
votes
1 answer

Maven - UnsatisfiedLinkError with java.library.path

I'm having a problem with trying to get Maven to load my native library. Currently, I placed my library file (.so) in src/main/resources/ and it gives me an error of it cannot be found in java.library.path. I also tried to place this in my base…
Hank
  • 3,367
  • 10
  • 48
  • 86