Commit 13ead804 authored by Martin Deinhofer's avatar Martin Deinhofer
Browse files

improved some comments

parent cee3b60b
......@@ -2,14 +2,13 @@ package java_exercises7_1_1;
public class HelloJNI {
static {
System.loadLibrary("hello"); // Load native library at runtime
// hello.dll (Windows) or libhello.so (Unixes)
System.loadLibrary("hello"); // Load native library at runtime: hello.dll (Windows) or libhello.so (Unixes)
}
// Declare a native method sayHello() that receives nothing and returns void
// Declare a native method sayHello() with the keyword 'native' that receives
// nothing as parameter and returns void
private native void sayHello();
// Test Driver
public static void main(String[] args) {
new HelloJNI().sayHello(); // invoke the native method
}
......
......@@ -2,20 +2,26 @@ package java_exercises7_2_1;
public class HelloJNI {
static {
System.loadLibrary("java_exercises7_2_1_HelloJNI"); // Load native library at runtime
System.loadLibrary("java_exercises7_2_1_HelloJNI"); // Load native library at runtime. In this case the library
// name has the java package prefixed to make the lib name
// unique.
}
// Declare a native method sayHello() that receives nothing and returns void
// Declare native methods with the keyword 'native'. Only the signature is
// provided, the implementation is in the native library.
private native void sayHello();
public native int intMethod(int n);
public native boolean booleanMethod(boolean bool);
public native String stringMethod(String text);
// Test Driver
public static void main(String[] args) {
HelloJNI helloJNI=new HelloJNI();
System.out.println("returned native nr: "+helloJNI.intMethod(2));
System.out.println("Returned boolean value: "+helloJNI.booleanMethod(true));
System.out.println("Returned string value: "+helloJNI.stringMethod("Test String"));
HelloJNI helloJNI = new HelloJNI();
System.out.println("returned native nr: " + helloJNI.intMethod(2));
System.out.println("Returned boolean value: " + helloJNI.booleanMethod(true));
System.out.println("Returned string value: " + helloJNI.stringMethod("Test String"));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment