java-tutorials/jni/src/main/java/com/baeldung/jni/ExampleParametersJNI.java
Miguel Rivero 62b5a591af BAEL-1637: Guide to JNI(Java Native Interface) (#4066)
* BAEL-1546: Java 8 Math additions

* Applied feedback to Unit Tests

* BAEL-1546 Added missing test annotations

* Added code for BAEL-1637

* Added script for Windows C++ code compile

* Added compilation script for MacOS

* Added some Unit tests
2018-05-15 22:18:41 +01:00

21 lines
810 B
Java

package com.baeldung.jni;
public class ExampleParametersJNI {
static {
System.loadLibrary("native");
}
public static void main(String[] args) {
System.out.println("Java: My full name: " + new ExampleParametersJNI().sayHelloToMe("Martin", false));
long sumFromNative = new ExampleParametersJNI().sumIntegers(456, 44);
System.out.println("Java: The sum coming from native code is: " + sumFromNative);
}
// Declare another method sumIntegers that receives two integers and return a long with the sum
public native long sumIntegers(int first, int second);
// Declare another method sayHelloToMe that receives the name and gender and returns the proper salutation
public native String sayHelloToMe(String name, boolean isFemale);
}