- There will be a new file called `A3.h` in your current working directory,
- This is the header file.
- It contains signatures for native functions we created in the Java file.
- Thus, there's **no need to memorized `A3.c` file** since the functions defined in that file can be found in the header file.
- Create a new `A3.c` file which is the C program file containing function definitions (for add, sub, mul, div)
- Define all the functions (add, sub, mul, div)
- Then, we have to compile the C program file, i.e. `A3.c`. For this, run `gcc -shared -o libA3.so -fPIC -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/linux" A3.c`,
-`gcc` -> GNU compiler for C program
-`-shared` -> tells the compiler to create a shared file (.so) instead of a regular executable file
-`-o libA3.so` -> tells the compiler to save the output to `libA3.so` file
-`fPIC` -> stands for Position-Independent Code. Needed for creating shared libraries.
-`-I"$JAVA_HOME/include"` and `-I"$JAVA_HOME/include/linux"` -> `-I` flag used for specifiying directories to include. Values in double quotes are directories
-`A3.c` -> name of the C program file to compile
- Lastly, run the program using `java -Djava.library.path=. A3`
-`java` -> Loads Java Virtual Machine (JVM)
-`-Djava.library.path=.` -> `-D` is used to set a system property. In this case, we’re setting the `java.library.path` (for .so or .dll files) property.
-`A3` -> name of the Java class containing the main method