I am attempting to install jzmq, the Java ZeroMQ binding, from the Maven repository (http://search.maven.org/#search|ga|1|a%3A%22jzmq%22). When added as a dependency to my pom.xml[1] Maven downloads the main jar, which provides a Java library, as expected. In addition to the main library, jzmq requires a native code library which Maven does not appear to download. At run time the Java library raises an exception due to the missing native code library.
The native library is provided in the repository and the pom.xml[2] file for jzmq appears to specify that the native library (libjzmq.so) should be downloaded. If I download the library and set the native library location manually it all works, I would however prefer if this could be automated via Maven.
I am unsure as to why Maven is not downloading and installing the native library, any advice or suggestions as to how to resolve this problem would be greatly appreciated.
I am running the latest Ubuntu release using OpenJDK and Apache Maven 3.0.4
[0] The exception that is raised when using jzmq as provided by Maven, sans the crucial native code library.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jzmq in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1874)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1087)
at org.zeromq.ZMQ.<clinit>(ZMQ.java:39)
[1] My pom.xml where jzmq is added as a dependency
<dependency>
<GroupId>org.zeromq</groupId>
<artifactId>jzmq</artifactId>
version>2.2.2</version>
</dependency>
[2] The pom.xml for jzmq where the native library is referred to
<profile>
<id>Linux</id>
<activation>
<property>
<name>os.name</name>
<value>Linux</value>
</property></activation>
<properties>
<native.os>${os.name}</native.os>
<native.path>src/.libs/libjzmq.so</native.path>
<!-- Use platform-specific path separators here: -->
<native.library-path>src/.libs/</native.library-path>
</properties>
</profile>
You need tell Java where to find the native library.
java -Djava.library.path=/usr/local/lib xxxxx
To run jzmq, you need 2 things,
refer to http://zeromq.org/bindings:java for detail
To avoid the configuration trouble, I believe you can check how to embed the native lib. When class "org.zeromq.ZMQ" initialises itself, it will try to load the embedded lib first,
static {
// if no embedded native library, revert to loading from java.library.path
if (!EmbeddedLibraryTools.LOADED_EMBEDDED_LIBRARY)
System.loadLibrary("jzmq");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With