- Qt 6.9
- Qt Core
- C++ Classes
- QJniEnvironment
- Qt 6.9.2 Reference Documentation

# Obsolete Members for QJniEnvironment

The following members of class QJniEnvironment are deprecated. They are provided to keep old source code working. We strongly advise against using them in new code.

## Public Functions

`(deprecated in 6.2)` bool | registerNativeMethods(const char *className, JNINativeMethod[] methods, int size)

## Member Function Documentation

### `[deprecated in 6.2]` bool QJniEnvironment::registerNativeMethods(const char *className, JNINativeMethod[] methods, int size)

This function is deprecated since 6.2. We strongly advise against using it in new code.

Use the overload with a const JNINativeMethod[] instead.

Registers the Java methods in the array methods of size size, each of which can call native C++ functions from class className. These methods must be registered before any attempt to call them.

Returns `true` if the registration is successful, otherwise `false`.

Each element in the methods array consists of:

- The Java method name
- Method signature
- The C++ functions that will be executed

     JNINativeMethod methods[] = {{"callNativeOne", "(I)V", reinterpret_cast<void *>(fromJavaOne)},
                                  {"callNativeTwo", "(I)V", reinterpret_cast<void *>(fromJavaTwo)}};
     QJniEnvironment env;
     env.registerNativeMethods("org/qtproject/android/TestJavaClass", methods, 2);

This is an overloaded function.