native keyword, methods, Java Native Interface (JNI)

native keyword is used to call a method which is written in some other language other than Java. This method is known as a native method.


native type method() ;

After declaring a method as native, it is written for the Java code. Usually C language is used to write the native methods. The process of using C code with Java code is known as JNI (Java Native Interface).

Disadvantages of native methods:

1) Native methods are stored with .DLL (dynamic link library) file extensions in Windows. DLL files are machine dependent. Thus, native methods are not portable.

2) Since native methods use machine code, it can lead to serious security issues.

Leave a Reply