Java Native Keyword

Ads
 

Java Native Keyword

Native is a Java keyword that is used in method declarations to specify that the method will not be implemented in another language, not in Java.

Native is a Java keyword that is used in method declarations to specify that the method will not be implemented in another language, not in Java.

Java Native Keyword

     

Native is a Java keyword that is used in method declarations to specify that the method will not be implemented in another language, not in Java. This keyword signals to the Java compiler that the function is a native language function i.e. its implementation for is written in another programming language because of the native keyword. For example you can write machine-dependent C code and invoke it from Java.

The usual means of write such methods is JNI (Java Native Interface). The Java Native Interface (JNI) comes with the standard Java Development Kit (JDK) from Sun Microsystems. It permits Java programmers to integrate native code (currently C and C++) into their Java applications. The Java Native Interface (JNI) is also known as programming framework, which lets a native method utilize Java objects in the same way that Java code uses these objects. The primary goal of JNI is binary compatibility of native method libraries across all Java virtual machine implementations on a given platform.

  The signature of native method looks like this: 

public native void method();

 

Ads

Ads