Previous | Next | Trail Map | Integrating Native Methods into Java Programs | Table of Contents


Integrating Native Methods into Java Programs

A native method is a Java method (either an instance method or a class method) whose implementation is written in another programming language such as C. The lessons in this trail show you how to integrate native methods into your Java code. Note that, currently, the Java language only provides a mechanism for integrating C code into Java programs; thus the lessons on this trail focus on writing native methods in C.


WARNING! The programming interface for implementing native methods in Java is under construction. Use these interfaces at your own risk and in full knowledge that they will change in future releases of Java. The examples and information contained here reflect the JDK1.0 release.

Step By Step walks you step by step through a simple example (the "Hello World!" of native methods) to illustrate how to write, compile and run a Java program with native methods.

Implementing Native Methods shows you how to implement both the Java side and the C side of a native method. This lesson includes information about passing arguments of various data types into a native method and returning values of various data types from a native method. This lesson also describes many useful functions that your native method can use to access Java objects and their members, create Java objects, throw exceptions, and more.


Previous | Next | Trail Map | Integrating Native Methods into Java Programs | Table of Contents