Flash cards
Review the key moves
What is the main idea behind Java native Keyword?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
Which statement best captures the main point of this lesson?
Complete the missing token from the example code.
___ Main {Put the learning moves in the order that makes the concept easiest to apply.
❮ Java Keywords
Example
Load a method from a compiled library:
class Main {
static {
System.loadLibrary("libraryname");
}
public static void main(String[] args) {
test();
}
private static native void test();
}Definition and Usage
The native keyword declares a method as belonging to an external compiled library which is native to the operating system.
In order to use native methods, an external library must be loaded from a .dll , .so or similar kind of file. The compiled code in the external file should be written to support the Java Native Interface.
❮ Java Keywords