I'm investigating zeromq as a message passing solution in a java project, but I find the instructions on java binding somewhat difficult to follow. http://www.zeromq.org/bindings:java
I am unfamiliar with java bindings, so these may be stupid questions, but can someone help me understand:
- Why do I need to install anything?
- Will jars I build on one machine work on another system? I need this application to be portable.
- If so, why do I need to build my own jars to begin with?
I feel like the instructions provided on zeromq require base familiarity with building C projects that I lack, so perhaps I am just being dense, but this seems like a lot of work.
As a fellow user of the Java binding of ZeroMQ, I sympathize. ZeroMQ is definitely one of the more challenging Java dependencies to manage. In it's heart of hearts, ZeroMQ is native C code and the Java binding is a (relatively) light weight wrapper around a JNI interface to the core ZeroMQ library and this is why it is complex to deploy.
As an aside - if ZeroMQ is a good match for your application, it's well worth the trouble because there really is nothing quite like it. Unfortunately this means you need to go through all these steps to get it working so you can decide if it is what you really need.
ZeroMQ for Java is based on three components:
Yes. The jar will be portable. You can build it on any machine and deploy it on any other. However thats the easy part. The hard part is creating the various DLLs that are required and those are not portable. Let's say you want to support Windows, Mac and Fedora Linux. You will need native development environments on Windows, Mac and Fedora and build the DLLs for each platform you want to support.
I don't know enough about Linux to say whether a DLL built on one distribution (say Fedora) will run on another (say Debian). If not, then you have more work ahead.
Anyhow, your application will be portable - ZeroMQ and JZMQ can run on a huge number of platforms - but you will need to have tight control over your deployment process to ensure that when you install each platform, the jar and the appropriate set of DLLs are installed, and they are installed in the right place.
Technically you don't. But I think they recommend doing the
make install
step so that the include and library files are where the compilers expect them and also so that Java can load them when it is time to run your program.I'm not a committer so I cannot say for sure. I expect part of it is developer efficiency - they would rather be improving the code than creating jars for users who could create the jars themselves.
More importantly - since the jars are not enough and you have to build the DLLs anyways, it makes more sense to build the jars and DLLs together. That way you are certain the JNI wrapper has exactly the right native methods implemented in C to match the native declarations in the Java wrapper class.
Good luck. Hope this helps.
Personally I do think pre-made JARs would go a long way to helping 0MQ in java. While I work in Java at many sites, they do not provide MSVS and having to go through such a lengthy setup just to get a dll and jar seems counter productive to me.
You can also look at JeroMQ (Pure Java implementation of libzmq).
JeroMQ is a full Java stack that uses the same protocol and API of ZeroMQ and is an official project of the community. It makes life a lot simpler for Java users since there's no JNI, no C++ to build. It does everything ZeroMQ does except PGM multicast.