Code written in other programming languages, such as C, C++, and assembly is usually called native code.

Fun Point

Insurance agent: "This is a particularly good policy, madam. Under it we pay upto a thousand pounds for broken arms and legs."

Woman: "Good heavens! What do you do with them all?"

The problem with arithmetic

Teacher: "Ravi can you tell me how fast light travels?"

Ravi: "I don't know but it always gets home too early in the morning."

Chapter 3

Java Native Interface


Java Native Interface is used for writing Java native methods and embedding the Java virtual machine into native applications.

In this chapter, you will learn how to embed the Java virtual machine into a C program. The source code needed for this chapter is stored in the examples\Chapter3 directory. The "Chapter3" directory contains the following files:

The example given below calls the main method of the MyFrame class.

Listing 3.1 Test.c (Complete code)

/*The #include directive treats
text in the file specified by
filename as if it appeared in the
current file.*/
#include <windows.h>
#include <stdio.h>
#include <jni.h>

//The #define directive defines a macro.
#define MAIN_CLASS "MyFrame"
Contents         Top                              Move to the preceding page Move to the next page
© 2001 All rights reserved