The env pointer is a structure that contains the interface to the JVM. It includes all of the functions necessary to interact with the JVM and to work with Java objects.
Questions tagged [jnienv]
195 questions
2
votes
3 answers
Why does the JNI C API use a pointer-to-pointer instead of straight pointers for JNIEnv?
Disclaimer: I have implemented my own object-oriented programming languages, so am familiar with (and have taught) pointers and C. Memory management 101 is not what this question is about. Neither is this about the JNI C++ API that looks similar.…

uliwitness
- 8,532
- 36
- 58
2
votes
1 answer
Accessing struct via pointer in C and C++
"Simple" question put short:
Why exactly does
JNIEnv *g_env = NULL;
(*g_env)->ExceptionDescribe(g_env);
compile in gcc (C)
but not
in g++ (C++)
error: base operand of ‘->’ has non-pointer type ‘JNIEnv’ {aka ‘JNIEnv_’}
As I am working mainly with…

Paxi1337
- 85
- 8
2
votes
2 answers
JNI Linux segmentation fault
My JNI library works flawlessly on Windows, however, on Linux I always get a strange segmentation fault.
siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000000000000
The stack crace from the crash file is this:
C …

Lóránt Viktor Gerber
- 694
- 9
- 22
2
votes
1 answer
Android calling Java function from another activity class in C++ JNI code
As the title suggested, How can I call Java function from C++ if the function is from a different java activity class?
All of the sample and tutorials calls C++ function and java back and forth but the caller is the class and the JNIEnv and jobject…

user2300947
- 450
- 4
- 14
2
votes
1 answer
NewDirectByteBuffer returning weird values
I have read many SO Q/A but I really can't get this to work.
I need to work with a vector in C++ (a library needs it) in a JNI project.
So I am calling a C++ method which initializes the vector and returns a pointer to the underlying array. Java is…

lorenzop
- 525
- 4
- 19
2
votes
0 answers
NDK get instance of AssetManager through JNIEnv (Xamarin.Android, C++)
I'm writing a Xamarin Android App which contains a native C++ library.
That native library contains a function which should load an image via the assetmanager.
C++
#include
#include
void…

Florian
- 465
- 5
- 17
2
votes
1 answer
How to release the jbyteArray?
My native method has a method with a byte[] return value, So I use "NewByteArray" to alloc the byte[],then use return to return the jbyteArray.
Should I release the jbyteArray? And how to release the jbyteArray?
Thank you. I am a Java beginner and…

iseki
- 63
- 1
- 12
2
votes
1 answer
android JNI report can't find method
I'm using the following code for wrapping all the native functions
package com.user.game;
import android.content.res.AssetManager;
public class MyGLRenderer {
static {
System.loadLibrary("Engine");
}
public static native void…

quetzalfir
- 528
- 7
- 22
2
votes
2 answers
Returning local reference created by JNI from a native method
JNI reference says that
"Local references are valid for the duration of a native method call. They are freed automatically after the native method returns.
Source:…

Vladislavs Burakovs
- 403
- 6
- 12
2
votes
1 answer
JNI GetFieldID returning null for inner class
I have public inner class which i want to access in JNI. GetFieldID is returning null while accessing fieldId for inner class
Below is code
public class classA{
public class classB{
public int b1;
}
public int a1;
public classB…

Sa Ku
- 21
- 2
2
votes
2 answers
Call Java function with parameter Map from c++ with std::map
How can I call Java function which takes Map as parameter from C++ when I have std::map in c++.
I know how to call Java function from c++ when parameters are simple types as int and so on but how to call for…

PaolaJ.
- 10,872
- 22
- 73
- 111
2
votes
0 answers
Qt JNI : Invalid indirect reference 0x61382e48 in decodeIndirectRef
I am trying the Qt project that captures audio data from mic on android.
I refereed this article : Android AudioRecord example, and wrote it to Qt code.
int recorderSampleRate = 44100;
int recorderChannels =…

covernal
- 329
- 1
- 3
- 20
2
votes
1 answer
Android JNI Callback to java from C++
I tried to create a callback from jni to java, But when ever execute my code from cpp thread, findClass method return null, But the same class path & method properly executing from jni thread(Native Thread).
static JavaVM * s_Jvm;
JNIEXPORT jint…

user2851150
- 397
- 5
- 12
2
votes
2 answers
Android Jni : crash in global and local ref variables
I have jni c++ code that calls java objects methods, example :
jclass JIOManager = CJavaEnv::getInstance()->env()->FindClass(ioManagerName);
..... some code
CJavaEnv::getInstance()->env()->DeleteLocalRef(JIOManager);
this works really fine…

Kamilia
- 195
- 1
- 2
- 13
2
votes
2 answers
JNIEnv for get ANDROID_ID from native code
I need to get Android unique device ID in my native library. As far as i know, it can be done with Java API and i need to use JNI. I read this, there is similar problem, but different ID is accessed. But this solution needs reference to JNIEnv for…

exbluesbreaker
- 2,160
- 3
- 18
- 30