Rakesh J R
Rakesh J R

Reputation: 31

Writing JNI for an existing C Library

Below is my scenario

I have to develop a java code that needs to communicate with C Library ( DNP3 Library ) , i assume below are the steps

  1. Understand the C code
  2. Write a JNI wrapper for C code
  3. Wite a Java program to call the JNI which in turn calls the C code

I have never worked on JNI , going through few examples i found they write the java code first and generate a .h file (JNI ) and then a corresponding C file.

Can you please reference me to any article that goes the other way round like C library (.c) -> JNI -> Java code ?

Thanks in advance Rakesh

Upvotes: 0

Views: 646

Answers (1)

Botje
Botje

Reputation: 30830

Look at SWIG for a low level Java abstraction of your C library, then build a higher level Java library on top of that. This is a common approach when creating language bindings.

Upvotes: 1

Related Questions