Building JARs with native libs inside

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Building JARs with native libs inside

Martin
Hi,

I like a lot the JOGL mecanism for packing and distributing native libraries into jar which autoselect according to the running OS and device.

I am willing to use this mecanism to pack native libraries but after spending a bit of time in jogamp-scripting project under the maven folder, would enjoy a bit of help about it :D

Is there a bit of doc somewhere explaining how to bundle .so/.dll/dylib in jar files and then perform the automatic selection of the appropriate one at runtime?

Thanks :)
Reply | Threaded
Open this post in threaded view
|

Re: Building JARs with native libs inside

gouessej
Administrator
Hello

It works very well except when some paranoid virus scanners get in our way. Can you tell me more about the native libraries you wish to pack?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Building JARs with native libs inside

Martin
Thank you for asking.

I am working with VTK, a powerful open source visualization framework using JOGL for Java rendering. VTK has a great data model for holding and processing geometries of any kind. It is for Jzy3D a good help for pre-processing geometries and building charts.

I use Maven a lot and am willing to pack VTK for Java with its native libraries for each platform bundled in a jar as JOGL does. I want to use VTK Java from any application using Maven easily and JOGL native packaging seems like a good solution.

I basically have one folder of native libs per platform. I wonder where are existing Jogamp scripts to pack them in a Jar, and then to auto-select the appropriate native according to the executing computer. Do you have hints on this? I found nar-maven-plugin and native-lib-loader doing similar things but none is doing the entire work.

As we are discussing native : have you read about JEP-412? Do you think this will be compatible with GlueGen?
Reply | Threaded
Open this post in threaded view
|

Re: Building JARs with native libs inside

gouessej
Administrator
I know VTK, I used it ten years ago.

I'll investigate when I have some spare time. I think that it's done in an Ant script, don't expect a solution based on Maven.

GlueGen doesn't use JEP 412. In my humble opinion, it would be nice to use the alternative to direct NIO buffers, the resource scope, etc.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Building JARs with native libs inside

farrellf
In reply to this post by Martin
I'm not sure about how to automate the Jar build process, but jSerialComm (a cross-platform serial port library) also packs their natives into a fat jar, and it looks like this is how they manage unpacking the jar at runtime:

https://github.com/Fazecast/jSerialComm/blob/master/src/main/java/com/fazecast/jSerialComm/SerialPort.java#L52
Reply | Threaded
Open this post in threaded view
|

Re: Building JARs with native libs inside

gouessej
Administrator
In reply to this post by Martin
Martin, have a look at JNILibLoaderBase and DynamicLibraryBundle in GlueGen. You can easily follow the native layout expected by GlueGen by using zipfileset with prefix in Apache Ant.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Building JARs with native libs inside

Martin
Thank you both for your suggestions. I'll try all this and will tell you when it works.

Best,

Martin