> For the complete documentation index, see [llms.txt](https://ref.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ref.gitbook.io/notes/c-c++/jni.md).

# JNI

Pass 2d array from Java:

```cpp
static void releaseMatrixArray(JNIEnv *env, jobjectArray matrix) 
{
	int size = env->GetArrayLength(matrix);
	
	for (int i = 0; i < size; i++) 
	{
		jfloatArray oneDim = (jfloatArray) env->GetObjectArrayElement(matrix, i);
		if (oneDim) {
		 jfloat *elements = env->GetFloatArrayElements(oneDim, 0);

		 env->ReleaseFloatArrayElements(oneDim, elements, 0);
		 env->DeleteLocalRef(oneDim);
		}
	}
}
```
