Chapter 12. JNI Types

This chapter specifies the standard data types defined by the JNI. C and C++ code should include the header file jni.h before referring to these types.

Primitive and Reference Types

The JNI defines a set of C/C++ types that correspond to the primitive and reference types in the Java programming language.

Primitive Types

The following table describes the primitive types in the Java programming language and the corresponding types in the JNI. Like their counterparts in the Java programming language, all primitive types in the JNI have well-defined sizes.

Java Language Type

Native Type

Description

boolean

jboolean

unsigned 8 bits

byte

jbyte

signed 8 bits

char

jchar

unsigned 16 bits

short

jshort

signed 16 bits

int

jint ...

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.