Is there an alternative to JNI on MacOS?
If you want to call Mac OS C code from your Java code, there are currently two mechanisms for doing so: JDirect2 and the Java Native Interface (JNI). Each has advantages and disadvantages. Generally you would want to use JNI if:
- You are writing your Java code and C code concurrently
- You want your code to be cross-platform
- You need to access full Java functionality from your C code (for example, if you need to manipulate Java objects in C)
JDirect is useful if:
- You want to call older C functions from Java, or code whose source you cannot change (for example, legacy code or system software functions).
- You do not want the overhead of writing C glue code to establish a JNI environment and translating parameters for native calls