Chapter 2. Getting Started

This chapter walks you through a simple example of using the Java Native Interface. We will write a Java application that calls a C function to print “ Hello World! ”.

Overview

Figure 2.1 illustrates the process for using JDK or Java 2 SDK releases to write a simple Java application that calls a C function to print “ Hello World! ”. The process consists of the following steps:

Steps in Writing and Running the “Hello World” Program

Figure 2.1. Steps in Writing and Running the “Hello World” Program

  1. Create a class (HelloWorld.java) that declares the native method.

  2. Use javac to compile the HelloWorld source file, resulting in the class file HelloWorld.class. The javac compiler is supplied ...

Get Java™ Native Interface: Programmer’s Guide and Specification, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.