The H3 library is implemented in C, so the Java bindings must use a version of the native H3 library built for your system.
H3-Java uses JNI to interface with the native H3 library. Because of requirements for how JNI functions are called, additional functions must be included in the native H3 library.
For most users, running mvn package
is sufficient to build the library. Read on if you want to modify the build process in some way.
When building H3-Java, the build process goes through the following steps:
- Compiles the Java sources and generates a header file for the JNI-specific native functions.
- Downloads the sources for the H3 library. The version number set in the H3-Java project is used.
- Builds the native H3-Java library for the current platform, which includes the H3 library and the JNI-specific functions.
- Builds the native H3-Java library using dockcross for supported platforms.
- Copies all built library files into the resources of the built JAR.
You can use the Maven properties h3.git.remote
and h3.git.reference
to control where the H3 library is cloned from, and which revision is used respectively.
If you need to modify the build of the native library, modify the file ../src/main/c/h3-java/build-h3.sh and ../src/main/c/h3-java/CMakeLists.txt as needed. You may also need to modify the operating system and architecture detection code in src/main/java/com/uber/h3core/H3CoreLoader.java.
You can use the Maven property h3.use.docker
to disable the dockcross-based cross compilation step.
Relocating the H3 classes may not work, because some class names are hard coded in the JNI code.