The Java class consists of two instance functions. Native code invokes these two instance functions and displays the outputs as shown below.
C:UsersUserDesktop>java Process
Key in your first number: 10
Key in your second number: 2
The addition of two numbers = 12
The subtraction of two numbers = 8
The multiplication of two numbers = 20
The division of two numbers = 5
C:UsersUserDesktop>java Process
Key in your first number: 2
Key in your second number: 10
The addition of two numbers = 12
The subtraction of two numbers = 8
The multiplication of two numbers = 20
The division of two numbers = 5
The Java source code is provided. Write the C++ native code, show the print screen that involves JNI process (compile Java source code, generate the C++ header file, build shared library file, execute the Java file and two outputs (display twice from the same number with different position for the first and second number from the command prompt).
/ Process.java
class Process {
private native void calculate;
private int add(int n1, int n2) {
return n1 + n2;
}
private int multiple(int n1, int n2) {
return n1 * n2;
}
static {
System.loadLibrary("CProcess");
}
public static void main(String args) {
Process p = new Process();
p.calculate();
}
}