Cloned java native code example originally from dredwardhyde/jni-maven-example.
mvn compile
java -Djava.library.path=target -cp target/classes com.jni.example.JniWrapper
- Updated
.gitignore
for generated header and IntelliJ ide directory. - Updated maven pom version to
1.1-SNAPSHOT
, added removal of generated headers, added GCC debug flag for compling MacOS native code. - Added
artifacts/IntelliJ
.
Useful snippets:
- How to call javah from maven
- How to use native-maven-plugin on macOS
- Note you have to add JDK include folders on macOS
- How to use native-maven-plugin on Windows 10
- cl.exe arguments to build DLL
- link.exe arguments to build DLL
- How to load native library
- How to find object methods
- How to find static methods
- How to create new string
- How to call object method
- How to call static method
- How to delete references in JNI code
- How to find Java class
- How to create Java object
- How to return object from JNI method
Please note that on Windows 10 you need to build and install in local maven repository this project to get Microsoft Visual Studio 2017 support by native-maven-plugin