Installing ZeroMQ and Java bindings on Ubunu 10.10
For some times now, I'm following the slow evolution of AMQP toward it's 1.0 release. In the trip, one traveler decided that the road was far too long, and complex, and choosed to take its independence: ZeroMQ is living its own adventure for some times now. And their choices are intersting, really focused and sharp, so I needed to see what can be done with that message system, and a bit of Scala.
So the first part was to install ZeroMQ and its Java binding into my computer, a Linux Ubuntu 10.10. It was quite easy, but as I didn't find a single post for the whole thing, I write that one as a memo, when in some days I will try to do it again and won't be able to remind the precise steps :)
Step 1: install recent ZeroMQ libraries
Before playing with some code, you need to install ZeroMQ libraries on your system. That library is on Ubuntu 10.10, but a more recent version seems to be needed for Java bindings. That's not a problem as some good will has made a PPA repository for them:
% sudo add-apt-repository ppa:chris-lea/zeromq
% sudo aptitude install libzmq-dev
That should install libzmq-dev (header files needed for the Java bindings) and the libzmq0 package - the core messaging system itself.
Step 2: get ZeroMQ binding
For that, you will have to clone the github repository of the project
% git clone https://github.com/zeromq/jzmq.git
And with that, you have a new jzmq directory with everything needed to build the Java bindings.
Step 3: build and install jzmq package
We are on a Debian based distribution, and ZeroMQ guys have the good taste to provide all what is needed to build a .deb for JZMQ, so let's just use the good work.
In the former jzmq directory, just do:
% ./autogen.sh
% dpkg-buildpackage -rfakeroot
And that's it. If all goes well, you should have a "jzmq_[some-version]_i386.deb" package on the parent directory of the one you are in. Just install it as usual:
% dpkg -i jzmq_[some-version]_i386.deb
And now, you can use ZQM from you Java code.
Some last notes
* don't forget to add the JNI library path in you JVM command line: use -Djava.library.path=/usr/lib
(/usr/lib should contains libjzmq.so, you can see it with dpkg -L jzmq)
If you the JAVA_HOME environment variable was correctly set when you buit the package,you may not have to add that parameter.
* libjzmq.jar is in /usr/share/java/
* you will find some Java examples here.
That's it! Enjoy a world of easy message distribution.
2 comments:
Thanks for the post - you did a much better job than I :)
http://yansnotes.blogspot.com/2010_08_01_archive.html
Thanks for the blog post!
Just as a heads up, jzmq is provided through a PPA repository nowadays as well:
https://launchpad.net/~tuomjarv/+archive/jzmq
Enjoy!
Post a Comment