I understand that I need to look at using NDK and JNI to integrate C and Java, however all the tutorials seem to point at writing your own C code. I have been given a huge directory which includes .c files and corresponding .h files. I am told this C code has been produced by MatLab. Please bear in mind that I am a Java developer and my C knowledge is not great. Within this directory are 2 .mk files and a few other file types as well (.bat, .rsp, etc.), in total about 360 files. I need to build this implementation, be able to pass information to a few functions and receive information back as well.
What is the process I need to follow to achieve this? Because the information online speaks about creating header files etc.. however the header files in C already exist. I think my most important question is how do I integrate this and build it so I can then use JNI to interact with the C code?
The C application simply takes my inputs and does some maths and provides me an out put object with the data I require.
RegisterNatives). There are tools in the JDK that can create headers with correctly named C function declarations based on thenativemethod declarations in your Java code. And then it's up to you to write the C function definitions. Or you might look into using something like SWIG, which does some of this for you, but on the other hand you then need to learn how to use SWIG.foo, and you have it declared as anativemethod in the Java classcom.mycompany.MyClass. Then you'd write another C function namedJava_com_mycompany_MyClass_foowhich calls the actualfoofunction, and converts / passes along function arguments and return values as it does so. So you're not reimplementing all of your C functions; you're just adding some wrappers around the functions that you want to be able to call.