Java Native Interface - Purpose and Features

Purpose and Features

JNI enables one to write native methods to handle situations when an application cannot be written entirely in the Java programming language, e.g. when the standard Java class library does not support the platform-specific features or program library. It is also used to modify an existing application—written in another programming language—to be accessible to Java applications. Many of the standard library classes depend on JNI to provide functionality to the developer and the user, e.g. file I/O and sound capabilities. Including performance- and platform-sensitive API implementations in the standard library allows all Java applications to access this functionality in a safe and platform-independent manner.

The JNI framework lets a native method use Java objects in the same way that Java code uses these objects. A native method can create Java objects and then inspect and use these objects to perform its tasks. A native method can also inspect and use objects created by Java application code.

JNI is sometimes referred to as the "escape hatch" for Java developers because it enables them to add functionality to their Java application that the standard Java APIs cannot otherwise provide. It can be used to interface with code written in other languages, such as C and C++. It is also used for time-critical calculations or operations like solving complicated mathematical equations, because native code may be faster than JVM code.

Read more about this topic:  Java Native Interface

Famous quotes containing the words purpose and/or features:

    Possibly the Creator did not make the world chiefly for the purpose of providing studies for gifted novelists; but if he had done so, we can scarcely imagine that He could have offered anything much better in the way of material ...
    Elizabeth Stuart Phelps (1844–1911)

    The features of our face are hardly more than gestures which force of habit made permanent. Nature, like the destruction of Pompeii, like the metamorphosis of a nymph into a tree, has arrested us in an accustomed movement.
    Marcel Proust (1871–1922)