java-native-interface

Unicode const char* to JString using JNI and C++

跟風遠走 提交于 2020-03-22 07:31:28
问题 Simple question. How can I get a jstring out of a unicode const char*, using JNI and C++? Here's my issue, and what I have already tried: const char* value = (some value from server); (*env)->NewStringUTF(value); The issue here is that NewStringUTF returns a UTF string, and it does not like some of the non-UTF8 characters (kind of obvious, but worth a simple try). Attempt 2, using NewString: const char* value = (some value from server); (*env)->NewString(value, strlen(value)); While NewString

Weird Native Crash - pid: 0, tid: 0 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)

▼魔方 西西 提交于 2020-03-18 03:29:18
问题 I am getting this weird crash on android *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** pid: 0, tid: 0 >>> com.oimvo.discdj <<< backtrace: #00 pc 000000000001d050 /data/app/com.oimvo.discdj-2/lib/arm64/libavfilter.7.11.101.so (av_fastresampler_resample_s16+1944) #01 pc 000000000001c930 /data/app/com.oimvo.discdj-2/lib/arm64/libavfilter.7.11.101.so (av_fastresampler_resample_s16+120) and another similar crash *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** pid:

Weird Native Crash - pid: 0, tid: 0 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)

ぐ巨炮叔叔 提交于 2020-03-18 03:29:08
问题 I am getting this weird crash on android *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** pid: 0, tid: 0 >>> com.oimvo.discdj <<< backtrace: #00 pc 000000000001d050 /data/app/com.oimvo.discdj-2/lib/arm64/libavfilter.7.11.101.so (av_fastresampler_resample_s16+1944) #01 pc 000000000001c930 /data/app/com.oimvo.discdj-2/lib/arm64/libavfilter.7.11.101.so (av_fastresampler_resample_s16+120) and another similar crash *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** pid:

How to Display a Windows event Log details in jni the return data must be array of properties

守給你的承諾、 提交于 2020-03-03 14:00:59
问题 eventJava.java import java.util.*; public class eventJava{ static{ System.loadLibrary("event"); } public native Properties[] sayHello(); public static void main(String[] args) { try { Properties[] records = new Properties[1000]; records = new sayHello(); } catch (UnsatisfiedLinkError e) { System.out.println("Couldn't call native function.\n" + e); } // Create an instance and invoke the native method for(Properties record:records){ System.out.print("type:"+record.getProperty("type")); System

Eclipse - Failed to load the JNI shared library

痴心易碎 提交于 2020-03-01 04:22:18
问题 Every time I try to start Eclipse, it says Failed to load the JNI shared libraby "C:\Program Files (x86)\Java\jre7\bin\client\jvm.dll" I have no clue why this happens, because I reinstalled JDK, JRE and Eclipse multiple times. All the 64 bit version (I've got Windows 7 64 bit) 回答1: Alright, it somehow worked using the 32 Bit version of Eclipse... 回答2: If you have installed all 64 bit version of Eclipse and JDK, you can check your system environment variable. Probably you set on old JAVA_HOME

Android JNI native C function call kills activity

微笑、不失礼 提交于 2020-02-28 06:04:14
问题 What works: I have a c executable that runs a TUN/TAP service, and two shell scrips (to configure the "ip route" and "iptables") that run fine in terminal, all run as root. What doesn't work: I am attempting to create an Android App to run the c executable and shell scripts after a button is pressed. I originally made it such that onClick would create a process with processBuilder as shown below: final Button button1 = ... ... public void onClick(View v) { String ip_address = edIPAddress

Maven and native libraries

隐身守侯 提交于 2020-02-27 08:36:09
问题 I use maven in my java project, and I don't understand how to add in native libraries. In my non-maven project I did it via CLASSPATH. I use NetBeans and maven in my current java project. 回答1: If you just want to add the native libraries to the class path, try to put them in src/main/resources . Update: You can specify where resources exist in the POM: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven

Maven and native libraries

独自空忆成欢 提交于 2020-02-27 08:36:06
问题 I use maven in my java project, and I don't understand how to add in native libraries. In my non-maven project I did it via CLASSPATH. I use NetBeans and maven in my current java project. 回答1: If you just want to add the native libraries to the class path, try to put them in src/main/resources . Update: You can specify where resources exist in the POM: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven

Converting jni::sys::JNIEnv to JNINativeInterface defined in ffi

眉间皱痕 提交于 2020-02-25 04:06:30
问题 I am following up on Casting a borrowed reference with a lifetime to a raw pointer in Rust, which solved the wrong problem. Please consider the following code: extern crate jni; extern crate ffi; use jni::JNIEnv; use jni::objects::JClass; use jni::sys::{jint, jlong, jobject}; struct CameraAppEngine { _env: *mut jni::sys::JNIEnv, _width: i32, _height: i32 } impl CameraAppEngine { pub fn new(_env: *mut jni::sys::JNIEnv, _width: i32, _height: i32) -> CameraAppEngine { CameraAppEngine { _env,

ParcelFileDescriptor.createPipe in JNI

半世苍凉 提交于 2020-02-23 04:57:27
问题 I'm trying to figure out how I can pass a stream of data within ContentProvider.openFile . The data to be sent is created in JNI. I tried createPipe with a transfer thread but I had a ton of trouble with broken pipes. So I thought I might just pass the 'write' pipe to JNI and write the data directly to it. Java: ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe(); boolean result = ImageProcessor.getThumb(fd/*source fd*/, pipe[1].getFd()); //JNI call (formerly returned a byte[])