Reputation: 1021
H3 library is based on C code
And I would need to use it on a platform that only allows Java runtime to run.
Is it possible to compile C code to Java (jar) runnable on the JVM? Or embed a C runtime in the JVM?
Upvotes: 1
Views: 278
Reputation: 7795
Generally, C code can not be executed by the VM. While there are ways to compile C to Java (1, 2) this might not be the best solution for you.
The typical way to interact with native code would be over JNI (Java Native Interface)
Fortunately, you do not need to do this yourself. H3 already offers ready-made Java bindings:
https://github.com/uber/h3-java
You can simply use the bindings as dependency in your POM and then use the Java classes to interact with H3.
Upvotes: 2
Reputation: 4013
What you're looking for is the Java Native Interface (JNI). This allows you to create a binding between native code (written in, for example, C) and Java code.
Upvotes: 1