|Email article link|
Java Recipe of the Day
The following recipe is from The Java Cookbook, by Ian Darwin. All links in this recipe point to the online version of the book on the Safari Bookshelf.
26.6. Calling Java from Native Code
Starting from 1.1, JNI provides an interface for calling Java from C, with calls to:
Create a JVM
Load a class
Find and call a method from that class (e.g., main)
JNI lets you add Java to legacy code. That can be useful for a variety of purposes and lets you treat Java code as an extension language (just define or find an interface or class like Applet or Servlet, and let your customers implement it or subclass it).