> Alternatively you could package the library
> files for the various platforms as resources within the JAR and
> automagically load the right one at runtime

This is actually already how it's done, courtesy Karl Ostendorf (kwo).
The relevant bits:

https://github.com/zeromq/jzmq/blob/master/src/org/zeromq/EmbeddedLibraryTools.java

I'm mostly curious how to actually build the jar itself and assemble
.so, .lib and whatnot files for all platforms in a practical and
repeatable fashion.

I suppose we could do it manually on different platforms, merge
resources and resign the jar.
So far, this is what we've done locally, but it's not exactly elegant,
repeatable or scalable.

Are there any other projects that do similar distribution of embedded
native libs?

jna.jar is the only one i recall off the top of my head, and their
build file is a lovely 1000 lines of XML.

Maybe its too high a target to go for embedding everything for all
"supported" platforms.
Perhaps it would be more practical to ship libjzmq as a separate
(platform-dependent) package, and that being an implicit dependencyfor
installing the jzmq artifact?

On Thu, Dec 29, 2011 at 16:12, Gabriele Svelto
<gabriele.sve...@gmail.com> wrote:
>  Hi Daniel,
>
> 2011/12/29 Daniel Lundin <d...@eintr.org>:
>> This will solve the hosting/distribution problem neatly, and we can
>> focus on the tricky business - i.e how to build multi-platform jars
>> w/native code.
>>
>> Any Java-heads around here familiar with how that works in practice?
>
> it depends on how you want to distribute the native libraries. If the
> JAR assumes that the native library is already installed, it would
> just be a matter of calling System.LoadLibrary() with the correct
> library for the environment you're running on within static
> initialization methods (to make sure the library is loaded before any
> object is instanced). Alternatively you could package the library
> files for the various platforms as resources within the JAR and
> automagically load the right one at runtime using System.Load() after
> detecting the system you're running on.
>
> The tricky part is really figuring out where the JAR is running
> (Windows? Linux? BSD?) and then taking appropriate action. If the JAR
> file is meant to be platform-specific on the other hand then there's
> no need for this logic but you still need to distribute the
> appropriate native library somehow (either it's pre-installed or its
> packaged within the JAR).
>
>  Gabriele
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to