7

image Calling C from Java

This is also nontrivial and not for the faint of heart. Many examples are available online and once again the JNI support comes in useful. If you are planning to bridge between Java and any other Native language, you should thoroughly investigate and understand JNI first.

Here is an outline of what you need to do in order to call C from Java:

1.  Design the application and clearly define the interface boundary taking care to factor things into the Java or C language portion sensibly.

2.  Write your Java application and declare the native methods.

3.  Compile the code to produce a class file.

4.  Create a header file (.h ...

Get Developing Quality Metadata now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.