This repository shows two ways to interact with native methods from Java. Code is not ready to compile due to the use of absolute paths but feel free to use the code for reference. Below are the instructions at a high level to get this working.
- Compile the shared library
clang -shared -o libtriple.so triple.cc -Itriple.h
- Compile the java classes (using Graal javac compiler)
javac Headers.java Main.java
- Build the native image
native-image -cp . --verbose -Djava.library.path=. -H:CLibraryPath=. Main
- Run the application
./main
- Compile the shared library
clang -shared -o libtriple.so triple.cc -Itriple.h -INativeTriple.h -I/path/to/java/headers
- Compile the java classes
javac NativeTriple.java Main.java
- Run the application
java Main