Questions tagged [java-native-interface]

1

votes
1

answer
2.5k

Views

What does the difference of the JNI method CallObjectMethod,CallObjectMethodV and CallObjectMethodA?

There are 3 kinds of methods in JNI CallObjectMethod CallObjectMethodV CallObjectMethodA So what does the difference of the methods? jobject (*CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...); jobject (*CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list); jobject (*CallObjectMeth...
anql
1

votes
1

answer
624

Views

How to create an JNI Android Studio Project with multiple static libs

I'm converting our game from using ndk-build to using Android Studio and CMake. The app is a JNI app taking the following form: A Java main activity (single, very basic .java file) c++ app code (game code) c++ physics code (to be compiled and linked as a static lib) c++ graphics code (to be compile...
Steven Haggerty
1

votes
2

answer
89

Views

How are native methods for JDK loaded?

While reading JDK source code, I found that some methods are native, but there's no System.loadLibrary or System.load in their static block, so how are those methods actually loaded? So I guess those methods are built-in in the JVM. Just wonder how are them loaded for specific class. Say, StrictMat...
Rui Yang
1

votes
2

answer
1.2k

Views

Java Native Interface and Security

Is there any chance for the the violation of java security policy through java native interface. Which are the main areas we have to use JNI
Biju CD
1

votes
1

answer
98

Views

Could not find the class while using the java class inside the c++

I was following the https://www.ibm.com/developerworks/java/tutorials/j-jni/j-jni.html to use java class functions inside the c++ code.I am using the same code that they are using for Sample2.java. I did it in two different ways. First way : I copied and pasted the same code in 'sublime text editor'...
Enjal Parajuli
1

votes
0

answer
224

Views

jmethodID was NULL for a method with Kotlin

I am using a native library and having the exception below even though the method exists. I have a nativeInit function that is also exported to MapController and it works as expected. However, the nativeLoadScene method causes an error. JNI DETECTED ERROR IN APPLICATION: jmethodID was NULL in call t...
dgngulcan
1

votes
0

answer
22

Views

JNI and thread unsafe initialization

Suppose I am writing a JNI binding to a C library, which requires an initialization function to be called that isn't thread-safe. Given that the JVM doesn't serialize calls to JNI_OnLoad, how can I avoid racing against someone else's library that also binds to my library?
Demi
1

votes
0

answer
93

Views

JNI callback invocation when running multithreaded

Currently I try to get the stettbacher O-3000 cameras to get running with my Java client. For this I use JNI to invoke the driver functions. Everything works as expected. Here is the relevant part of my code: (Java) ... static { System.loadLibrary('o3000jni'); } ... private Camo3000JNI jni; private...
x4k3p
1

votes
1

answer
1.4k

Views

What is libJvm.so, and when is it built?

I'm a bit surprised that I have to post a question that looks rather trivial and easy to look up.... but it apparently isn't. Because it looks that my jni.h and the libJvm.so library are out of sync (or so I suspect), which shows up trying to load my Java application as a library into the C++ enviro...
SoHerman
1

votes
1

answer
39

Views

Microsoft Windows Advertising SDK in apps or software deployed outside of Windows App Store

Is it possible to use Microsoft Windows Advertising SDK to put Ads banners in an app or software that you do not deploy/upload to the Microsoft App Store? Say that you have some Windows XP, Windows Vista, Windows 7 etc software that is either in C/C++ or JAVA and you want to add Microsoft Advertisin...
htfree
1

votes
1

answer
475

Views

Android app loading ARM shared library on x86 device fails

I have a really simple android app. I want to load a shared library called 'libcamera.so' and then call methods via JNI. I do not own this library and I do not have access to the source code. It was originally compiled for ARM. An x86 version is not available. The project can detect the library and...
Bakwon
1

votes
0

answer
25

Views

android : type mismatch for native jni library

I am trying to build an AAR, which includes a static prebuilt C library and calls its functions through JNI. When I am including this AAR file in a different project and executing that APK. It runs on one target (say T1) but gives error on other Target(T2). The error says, in libs/arm64/lib.so - Th...
funny_geek
1

votes
1

answer
118

Views

How to pass a Java null parameter to a native method that uses JNA to compile to C code?

I'm trying to use a Java library that wraps the C library libudev. One of the methods I need to call, addMatchSubsystemDevtype(final String subsystem, final String devtype), takes two String parameters, the second of which needs to be a null. An example of this in C code can be seen here (ctrl+f nul...
dyslexit
1

votes
0

answer
77

Views

Java native interface and registering native methods

What is the difference between system.loadlirary () and registernative () in jni? Can registernative() method can be used to use .exe or .cpp without creating .dll? Is there any way to to achieve something like this?
Sri vishnu Bharat
1

votes
1

answer
714

Views

“A JNI error has occurred, please check your installation and try again” Sat4J

I wrote a java programm using Sat4J and it works fine. Now I want to export it as a jar-File, but when I execute it, it allways says 'A JNI error has occurred, please check your installation and try again Exception in thread 'main' java.lang.NoClassDefFoundError: org/sat4j/specs/TimeoutException' I...
Kathi
1

votes
0

answer
96

Views

segmentation fault while loading libutils.so in android

While loading your library, I am getting error on loading libutils. so I am new to NDK, so don't know much. Error log: I/CallRecLib: Error: dlopen failed: library 'libutils.so' not found 02-06 18:11:12.960 21141-21141/com.superreceptionist W/google-breakpad: ### ### ### ### ### ### ### ### ### ### #...
Abhishek Singh
1

votes
0

answer
63

Views

“undefined reference to” when using g++ -Wl,--add-stdcall-alias -shared -o

I am trying to build a JNI library to ed25519 I am able to compile the library and my bridge code, but then it fails when trying to merge back using -shared Those commands works: g++ -Wall -g -c Core/src/main/jni/ed25519/ed25519.c -I C:/work/OpenSSL/include -o Core/out/jni/ed25519.dll -m64 -O3 g++...
Ilya Gazman
1

votes
1

answer
63

Views

JNI and shared library

Trying to create dll. So first I created a .java file as follows: class Main { static { System.loadLibrary('sample_dll'); } static native void sritest(); public static void main(String [] a) { sritest(); } } Then I compile it with no error to .class. Then using javah I created Main.h. Then I write...
Sri vishnu Bharat
1

votes
1

answer
54

Views

Java loading a DLL that export methods from another DLL in JNI

i did a DLL that export methods from another DLL in JNI. JNIEXPORT bool JNICALL getIsWordInPhonemListFR(const char* word) { isWordInPhonemListFR method = NULL; BOOL fRunTimeLinkSuccess = FALSE; HINSTANCE hGetProcIDDLL = LoadLibrary(L'PhoneticEngineFR2.dll'); if (!hGetProcIDDLL) { std::cout
hugo411
1

votes
0

answer
134

Views

JNA : 'org.osgi.framework.BundleException: No Bundle-NativeCode match'

I am new to RCP applications and this might be a newbie question. I've been trying to add jna and jna-platform(4.5.1) to the application and I've been getting a 'org.osgi.framework.BundleException: No Bundle-NativeCode match' exception. I tried modifying the manifest.mf entry to have(as mentioned in...
nahzor
1

votes
1

answer
358

Views

Implementing a global key press for javafx methods

Is it possible to implement jnativehook with the javafx method .setOnKeyPressed() ? For example this is how it listens to key presses while the application is focused: ListView list = new ListView(); list.setOnKeyPressed(new EventHandler() { @override public void handle(KeyEvent event){ if (event.ge...
themaal
1

votes
1

answer
526

Views

Can't load vlcjni library: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList couldn't find “libvlcjni.so”

After extending support for Android 6.0+. The app is getting crash while playing video using VLC-SDK. Previously we have make changes in SDK library a little bit as per our project need. Hence can't make changes in vlc-SDK. I have tried the solutions as below: Adding ABI filters. Add gradle.proper...
Maverick
1

votes
0

answer
56

Views

W/Looper: Could not write wake signal, errno=89

When I use send message from a jni thread to this thread (ZWANJniThread) by 'Input' method, At beginning, it works, but when I create a new ZWANJniThread thread, sometimes, I get 'W/Looper: Could not write wake signal, errno=89' in log. Has any body experienced this Looper error or any hint to chec...
dong
1

votes
0

answer
49

Views

start Intent, onActivityResult, AsyncTask doesn't work after Java call from JNI

I have big issue with some actions after I call Java method from C by JNI. I can't start startActivityResult, AsyncTask, Intent etc from called java method. For example event onActivityResult is not fired. Does anybody know what cause this problem ? This is my called Java method: public void request...
Jackxl
1

votes
0

answer
155

Views

Errror show “libffmpeg.so:text relocations” on vitamio?

I have read Text relocation and crash in android 6.0 . But when I follow that's instruction error always show. Actually video had appear, but when I change to another application and back again to my app. The error 'Detected problems with app native libraries (please consult log for detail):libffm...
Akbar Grunge
1

votes
0

answer
347

Views

Open and write files in Android NDK

Why can't I open files in writing mode in C? I surely have all permisions, and the path is correct because it can be open in read mode. For example: file = fopen(path, 'r'); returns a correct file, but file = fopen(path, 'w'); always return null In the Java part I can write the file, so, the soluti...
Lyx
1

votes
1

answer
171

Views

How to resolve a Bad global or local ref passed to JNI error when calling a java method from native code

i searched through many answers for this problem but none of the seemed to match my case.I could not figure out where i am making the mistake.I create a native method in java and call it through jni.In the native method i get the reference of a java class method and call it from there My java class...
vickee
1

votes
1

answer
188

Views

JNI called with jstring parameters, but one of them becomes NULL

I'm calling native function from Java: String pathTemp = Environment.getExternalStorageDirectory().getAbsolutePath()+Const.PATH_TEMP String pathFiles = Environment.getExternalStorageDirectory().getAbsolutePath()+Const.PATH_FILES engine.init(someInt, pathTemp, pathFiles); And I have the native functi...
Shmuel
1

votes
0

answer
67

Views

How to call a method from a specific thread context using JVMTI and JNI?

We are using JVMTI and JNI to issue static method calls in method entry and method exit callbacks of the JVMTI. We have a need to be able to call a static method on a Thread Context other then the Thread Context that JVMTI has issued the callback on for the method entry and method exit callbacks. T...
Amy
1

votes
0

answer
79

Views

Speed difference between JAVA and JNI

I wanted to make my Android Studio code faster, so i translated some Java code to native C. Surprisingly, function written in c executes almost three time slower than java function. Also, i have applied ndk build optimization but that didn't change anything. My code: 1) Java function: private int[]...
Igor Vurdelja
1

votes
2

answer
62

Views

Native android library compile

I want to compile these code to be android native library. I have tried many techniques and follow many online example and it doesn't work. I will provide the link to the code and explain which part I want to compile. This the link https://github.com/zyq8709/DexHunter (I want to compile the code in...
Sword man
1

votes
0

answer
57

Views

Unable to use remap in c++ native in Android JNI

I am developing an Android application using Java. In my application, I am doing some image processing. So I am using c++ and Open CV for it and calling the c++ function through JNI. I am trying to convert equirectangular/spherical image to cubemap image. I found this link for conversion, https://co...
Wai Yan Hein
1

votes
1

answer
87

Views

JDK9 NetBeans Dev - compile error during JNI Tutorial

I have searched the entire web throughly for almost two days now and couldn't come up with a solution to my problem. I hope you guys can help me. This might be a little specific but I am sure sooner or later others will experience the same problems. I am currently using NetBeans Dev (Build 201803200...
el platin
1

votes
0

answer
77

Views

Cannot resolve corresponding JNI function error when using JNA with C++

This is the code I used for the native-lib.cpp file. extern 'C' { char *libName() { return (char *) 'My Math Shared Library'; } } I used this whenever implementing it in the main activity file package com.example.tenealaspencer.example; import android.support.v7.app.AppCompatActivity; import androi...
Teneala Spencer
1

votes
1

answer
95

Views

ioctl returns ENOENT trying to post URB request to Isoc device endpoint (accessed from android's JNI)

Looks like I missing some spice in Android/JNI... I'm trying to access custom composite USB device, connected to regular (not rooted) Android device over OTG USB. Device exposes several interfaces, Audio Streaming and CDC terminal among of them, enumerates fine and Audio is played when used by OS. W...
Dave
1

votes
0

answer
139

Views

OpenCV android NDK build error

I'm using NDK to use C++ native code in OpenCV through Android studio. Every thing is alright except when I'm running this project to an android device I have the following error Warning:Native C/C++ source code is found, but it seems that NDK option is not configured. Note that if you have an And...
Malik Mohrat
1

votes
0

answer
25

Views

Android JNI native library not packaged to apk

While transforming my project from eclipse to AS. I got a fatal error which caused by 'the lib not found ' problem. My project contains jni codes,compiled by ndk build system and managed by the 'Android.mk' file. After transformed I found that two of the libraries(.so) was not packaged into the apk...
cabin
1

votes
0

answer
62

Views

android studio lldb display std::vector's incorrect value

I debug JNI std:: vector code in the android studio, LLDB display std:: vector's element incorrect value, but the std:: vector memory is correct. the effect is below image: https://i.stack.imgur.com/9BVgF.png develop environment: MacBook Pro 10.12.6 Android Studio:3.1.1 LLDB: 3.1 The 'hello-libs' de...
king 王
1

votes
1

answer
30

Views

Android external library acess

I am attempting to access an Android shared object from an Android application that I am working on. Based on online information on how to do this I have created the following folder structure within my project: |--app: |--|--src: |--|--|--main |--|--|--|--jniLibs |--|--|--|--|--armeabi |--|--|--|-...
Steve Malek
1

votes
0

answer
85

Views

Unable to use multiple functions in single native C++ library file in Android

I am developing an Android application that is using C++ native library. I have integrated the c++ into my project and call the C++ function from Java through JNI successfully. But the problem is I cannot declare multiple functions in single C++ native library. This is my native C++ code in native-l...
Wai Yan Hein

View additional questions