Z. Adam
Z. Adam

Reputation: 191

Java JNI vs. Android NDK

Could someone explain how the Java JNI and the Android NDK differ, how they are the same and how they fit together? I haven't found anything that gives a good explanation of the differences between the two and I'm a little confused.

Thanks!

Upvotes: 18

Views: 6583

Answers (2)

Doug Stevenson
Doug Stevenson

Reputation: 317497

JNI is just the way that Java handles calling into native/C++ code, and calling back into Java from there. It has nothing to say about Android - it is a Java language feature.

The Android NDK is a way to write Android applications using code called by JNI. It's specific to Android and gives native code access to Android APIs at that level.

Upvotes: 28

Nerdy
Nerdy

Reputation: 1099

Android NDK(Native Development Kit) is basically a toolchain to reuse code written in C/C++(native code). It compiles the native code into native library. NDK is similar to a Android SDK, with primary difference of using SDK only for java codes. NDK is used in application developed for multiple platforms like iOS, Windows. Apps like Whatsapp, Instagram were developed using NDK.

Java code use JNI(Java Native Interface)to call functions from native library, like accessing the objects, methods, etc. Also the native code can access the java environment.

Upvotes: 5

Related Questions