keyboard_arrow_up


The JNI provides a recorded and reinforced requirements that allows applications published in other 'languages' to be known as from Java. Contacting Java from a software published in another terminology is also known as embedding, and the process needs an knowledge of the Invocation API. The JNI also provides a way for applications published in other 'languages' to call Java.




Before you get too strong into our conversation, you can be provided with some qualifications on how local techniques proved helpful prior to the launch of the JNI. In short, before JDK 1.1 local techniques were difficult to use because:




  • The requirements did not interface to the Java Virtual Machine (VM) at playback for icon search. It was believed that signs would be in an include computer file and collected in at compile-time. Unfortunately, this is not the way item surroundings work with powerful connecting. This strategy also designed a chance for out-of-date resource information, and avoided powerful changes to principles at playback.

  • The interface for embedding was unexplained.

  • There was no assistance for pinning (preventing garbage collection and activity of Java objects).

  • Java post were transformed to suggestions without assistance for large personality places, making internationalization difficult.

  • The nomenclature was really complicated.




With the launch of the JNI in JDK 1.1, local techniques have become much easier to use. To help you better understand the JNI, they will evaluate areas the actual JNI specifications to describe why you need to use it and what it allows you to do. The italicized items are immediate quotations from the JNI requirements, and the frequent written text is the annotation I've provided for quality. Once you know the "why" and "what" of using the JNI, they will concentrate on the "how." Remember that for brevity's benefit I make no effort to completely describe the JNI requirements. If you feel you need a for beginners on the JNI, be sure to evaluate the complete requirements (and also the tutorial), which shows up in the Sources part of this article.




Why do I need to use the JNI?




The conventional Java category collections do not assistance the platform-dependent functions essential to the applying.




You might need to set some device-specific qualities under system control, or accessibility a device-specific API.




You already have a collection published in another terminology, and wish to make it available for Java system code through the JNI.




You may want to reword the necessary system in Java, but this is not possible in every case. Many system collections on the 'Net have taken a tremendous period of your a chance to master (we're discussing millions of hours); spinning them in Java is not likely at any given time.




Unfortunately, using local techniques may not be the optimum remedy. When you use local techniques in computation-intensive projects like limited circles, which happen when you continuously call a operate, you may find that the process of establishing up factors, contacting the method, and getting the come back principles for each version of the cycle requires longer than the which it requires to operate the operate.




You want to apply a small part of time-critical system code in a lower-level terminology such as Set up.




You have published a S5620 Carlo system that mimics your profile, but it operates too gradually. You've tried the JIT (just-in-time) compiler, but it just doesn't do it for you.




What does JNI allow me to do?




Make, examine, and upgrade Java things (including arrays and strings).




If you are using the Invocation API for embedding you can take a two-dimensional range of post and successfully pass it to the Java system. If your C system is called from Java, you can make and come back an range of drifts or an range of post that will be recognized by the Java contacting technique.




Contact Java techniques.




The ability to a Java technique from C/C++ or Assembler is essential to the Invocation API. These JNI features allow us to fixed and non-static Java techniques with justifications.




Capture and toss exclusions.




Good developers increase and catch exclusions. Using C/C++ or Assembler local program code to increase exclusions makes for more easy to understand programs.




Fill sessions and obtain category details.




A foreign-language system can demand details about the category being packed.




Execute playback type verifying.




The factors are examined at playback, not statically as they were in the earlier implementation.




You can learn java to become a java developer and programing in Java has a very good demand today.