Codecademy Logo

Java Native Interface (JNI)

Print Cheatsheet

Compiling and Running JNI

Compiling and running a program that uses JNI requires a compiler, a JVM, a native method C generator, native header files, and all the library files that have been referenced in the program.

Native Libraries and JNI

Native libraries from third-party APIs may be integrated into JNI by simply ensuring the library files are added to the folders from which this program will be launching, and by making minor additions to the compilation statement.

JNI Definition

JNI stands for Java Native Interface. It is used to link Java programs and native languages together so that a Java program may take advantage of non-Java classes and methods.

Implementing JNI in Java

When implementing JNI on the Java side it is important to declare native methods using the keyword native. Implementation will be done in the native language in a different file. To initialize function names you can compile and generate headers using the Java file in the terminal.

JNI, Java, and C++

JNI lets programmers integrate C++ and Java to create cross-platform applications. Such an application has the ability to call C++ functions from Java, and to call Java methods from C++.