This is a discussion on What means by Java Native Interface?Benifits of its within the Java Programming forums, part of the Software Development category; Hi, What means by Java Native Interface?Benifits of its Thanks, Prasath.K...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| Hi, What means by Java Native Interface?Benifits of its Thanks, ![]() Prasath.K |
|
#2
| |||
| |||
| The Java Native Interface (JNI) is a programming framework that allows Java code running in the Java virtual machine (VM) to call and be called by native applications (programs specific to a hardware and operating system platform) and libraries written in other languages, such as C, C++ and assembly. The JNI is used to write native methods to handle situations when an application cannot be written entirely in the Java programming language such as 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 the JNI to provide functionality to the developer and the user, e.g. I/O file reading 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. Before resorting to using the JNI, developers should make sure the functionality is not already provided in the standard libraries. The JNI framework lets a native method utilize 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 valve" for Java developers because it allows them to add functionality to their Java Application that the Java API can't provide. It can be used to interface with code written in other languages, like C++. It is also used for time-critical calculations or operations like solving complicated mathematical equations, since native code can potentially be faster than JVM code. The JNI is not trivial and requires a considerable effort to learn, and some people recommend that only advanced programmers should use the JNI. However, the capability for Java to communicate with C++ and assembly removes any limitations on what function Java programs can perform. Programmers considering using the JNI should be aware that as mentioned before, the JNI is not an easy API to learn; only applications and signed applets can invoke the JNI; an application that relies on JNI loses the platform portability Java offers (a workaround is to write a separate implementation of the JNI code for each platform and have Java detect the Operating System and load the correct one at runtime); there is no garbage collection for the JNI side (JNI code must do explicit deallocation); error checking is a MUST or it has the potential to crash the JNI side and the JVM. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| class and interface in java | gkumar | HTML, CSS and Javascript Coding Techniques | 0 | 07-19-2009 07:10 PM |
| Const means? | jeyaprakash.c | C and C++ Programming | 3 | 11-24-2007 06:30 AM |
| How do I call the native API from Java? | oxygen | Java Programming | 2 | 08-06-2007 07:43 AM |
| Do we have interface to schedule a task like ITaskscheduler interface for desktop.... | theone | Mobile Software Development | 1 | 07-24-2007 10:29 PM |
| Java:Tutorial - Adding Buttons to your Interface | pranky | Java Programming | 0 | 02-23-2007 09:11 AM |
Our Partners |