<p>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.</p>

<p>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.</p>

<p>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?</p>

<p>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.</p>

[{'answer_id': 15327, 'author': 'Michael Neale', 'author_id': 699, 'author_profile': 'https://Stackoverflow.com/users/699', 'pm_score': 2, 'selected': False, 'text': '<p>As a simpler alternative to JNI, try JNA: <a href="https://jna.dev.java.net/" rel="nofollow noreferrer">https://jna.dev.java.net/</a>, may solve this hassle for you and be simpler (assuming it can do what you want).</p>\n'}, {'answer_id': 15367, 'author': 'stimms', 'author_id': 361, 'author_profile': 'https://Stackoverflow.com/users/361', 'pm_score': 3, 'selected': True, 'text': '<p>I strongly dislike make because of its implicit ruleset and treatment of whitespace.  Personally I would use cpp tasks (<a href="http://ant-contrib.sourceforge.net/cpptasks/index.html" rel="nofollow noreferrer">http://ant-contrib.sourceforge.net/cpptasks/index.html</a>) 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.  </p>\n'}, {'answer_id': 80099, 'author': 'catphive', 'author_id': 14978, 'author_profile': 'https://Stackoverflow.com/users/14978', 'pm_score': 1, 'selected': False, 'text': '<p>I\'m working on something similar right now. Be aware that using swig from swig.org is often easier as it generates the stubs to the native library for you.</p>\n\n<p>The short answer to your question is that the ant file should run the make file after the java library has already been built, as the native library depends on the swig generated header, which is generated from the java class files.</p>\n\n<p>If you are super familiar with ant, and don\'t want to learn a new system, then <a href="http://ant-contrib.sourceforge.net/cpptasks/index.html" rel="nofollow noreferrer">http://ant-contrib.sourceforge.net/cpptasks/index.html</a>, also linked by another poster, will let you build c++ in ant.</p>\n'}, {'answer_id': 87578, 'author': 'JesperE', 'author_id': 13051, 'author_profile': 'https://Stackoverflow.com/users/13051', 'pm_score': 1, 'selected': False, 'text': '<p>I\'d skip JNI entirely, and use an external program which writes notifications on standard-output. Java can then simply read from the programs output stream and generate whatever event is necessary. JNI is way too much work if all you want is to send simple notifications.</p>\n\n<p>Also, on Linux you can simply start "inotifywait" (with some suitable parameters, see "man inotifywait").</p>\n'}, {'answer_id': 1121295, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>You could also try the terp C++ tasks at <a href="http://codemesh.com/products/terp" rel="nofollow noreferrer">Codemesh</a>. They are not free but they offer a high level of abstraction coupled with the ability to discover/specify the C++ compiler and the ability to iterate over more than one compiler/processor architecture/compiler configuration for multiplatform builds.</p>\n'}]
['https://Stackoverflow.com/questions/15305', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1849/']