Getting ZeroMQ and Jzmq Running on Mac OS X
I found the install to be a tad onerous, with enough gaps and issues to be worth documenting, so here are the steps.
Credit to these links for the fixing the problems I ran into.
1. Install ZeroMQ.brew install zeromq
2. Install pkg-config. you’ll need it for the jzmq build.brew install pkg-config
3. You’ll have to symlink pkg.m4 into /usr/share/aclocal, also for the jzmq build.sudo ln -s /usr/local/share/aclocal/pkg.m4 /usr/share/aclocal/pkg.m4
4. Install the Java Developer Package from Apple’s ADC site: http://connect.apple.com/. You’ll need it because for whatever reason, the included JDK install on Mac OS X moved the /include directory, which contains the jni.h file, to some other location besides the directory containing /bin and /lib. I suppose I could have symlinked it, but this seemed cleaner. From their docs:
The Java Developer package puts an additional copy of the Java SE 6 bundle in
/Library/Java/JavaVirtualMachines/. This copy is installable without disturbing the existing system JDK.
The download, since Apple doesn’t like direct links, is under Downloads > Java. I used the Java for Mac OS X 10.6 Update 3 Developer Package download.
5. Set your JAVA_HOME to point to the new JDK. I usually stick this in .bash_profile.export JAVA_HOME=$(/usr/libexec/java_home)
6. Download jzmq, the java JNI lib for zmq. Uncompress and cd into that dir, and build it:./autogen.sh ./configure make make install
You’ll end up with the zmq.jar in /usr/local/share/java/ and the native lib in /usr/local/lib
7. Fire up your favorite IDE (I use Intellij), create a new project, and add the zmq.jar to your project.
8. However you run your code, you’ll want to pass the following flag to the VM as an arg. It tells it where to find the native lib-Djava.library.path=/usr/local/lib
In Intellij, this is in Run > Edit Configurations > New > VM Parameters
9. Finally, paste the code from the article into a new class, and run. Yay.
That should be it, let me know if you run into any issues.
This is a handy reference for getting 0MQ for Java working on OS X. This works on both Snow Leopard and Lion.
I would suggest using “./configure –prefix=/usr” in step 6 so as not to require step 8 at all, but its up to you.