5

I am going to create a java project that uses JNI. I want to deploy the project as a stand-alone application, but some modules might be used as libraries of other applications as well. I want to support different platforms and everything should be as painless as possible.

As far as I can see, I have the choice between the maven-nar-plugin, which wasn't updated for one and a half year now, and the native-maven-plugin, which seems less user friendly to me.

Do you have any experiences with one of them or recommendations which I should use?

Cephalopod
  • 14,632
  • 7
  • 51
  • 70
  • The GitHub page has been updated on 7. November 2010... – khmarbaise Jul 08 '11 at 09:50
  • That's true. I originally found this page https://github.com/sonatype/maven-nar-plugin but you are right, this repository https://github.com/duns/maven-nar-plugin was updated more recently. – Cephalopod Jul 08 '11 at 10:09
  • 1
    For what it's worth: development of maven-nar-plugin has now moved to [its own GitHub organization](https://github.com/maven-nar/maven-nar-plugin), unifying several of the GitHub forks. – ctrueden Oct 10 '12 at 19:50

3 Answers3

5

I've only used the maven-nar-plugin for standalone C/C++ apps, but it's worked very well for that.

As for JNI, I've been using the native-maven-plugin for a few years now on a sizable application. We use it to allow our Java apps to interface with other applications that only offer C APIs. I've actually found it pretty user-friendly. The documentation is pretty good and explains basic usage, but you still have to deal with the C compiler and linker and whatever options that are required for building.

We just pass it the compiler and linker commands and options, the source location, and the javah file locations and it works. I have to say that with all of the pain we've been through with JNI, the maven plugin is one of the few things that hasn't been a big hassle.

Jon7
  • 7,165
  • 2
  • 33
  • 39
1

The third slide in this presentation about the NAR Plugin by Mark Donszelmann of the Stanford Linear Accelerator Center compares the native-maven-plugin and the maven-nar-plugin. Quoting from slide 3, the pros and cons of the native-maven-plugin:

Pros

  • Very configurable

Cons

  • Did not run out of the box (no defaults)
  • No binary dependencies
  • Not cross platform (different profiles for different platforms)
Sean Bright
  • 118,630
  • 17
  • 138
  • 146
buzz3791
  • 1,683
  • 2
  • 20
  • 38
1

I've used a lot native-maven-plugin since one year to cross-compile C and C++ source code (with a profile for each platform options like compiler, compiler options, linker options, etc...). It works like a charm but I feel pretty alone in my situation. Now, I don't understand why C/C++ developper still use make or cmake tools from an other era. Maven is so better for managing versions and dependencies...