Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JNI and Java: ant calling make or make calling ant?

I'm just about to make my first trip into the world of JNI (Java Native Interface) to provide file system change notifications from platform specific C/C++ code to Java. That is unless someone suggest some brilliant library for doing this that I've missed.

Being new to JNI I've managed to find much documentation on the interface side of it and library generation side of it, but I've not found much on building the native library.

I've got an existing build based on ant for the pre-existing Java source, so I'm trying to work out if I should get ant to call make to create the library or if it's best to get make to call ant after creating the library?

Neither option jumps out as being terribly nice, but both seem better than trying to get ant to call a compiler to compile the code and generate the library directly.

like image 679
Free Wildebeest Avatar asked Aug 18 '08 22:08

Free Wildebeest


2 Answers

I strongly dislike make because of its implicit ruleset and treatment of whitespace. Personally I would use cpp tasks (http://ant-contrib.sourceforge.net/cpptasks/index.html) to do my C compilation. They are not as flexible as make but they are also far less complex and it will mean you don't have to burden your developers with learning make.

like image 196
stimms Avatar answered Sep 28 '22 02:09

stimms


As a simpler alternative to JNI, try JNA: https://jna.dev.java.net/, may solve this hassle for you and be simpler (assuming it can do what you want).

like image 25
Michael Neale Avatar answered Sep 28 '22 02:09

Michael Neale