Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run ZeroMQ with Java?

I'm having an issue running ZeroMQ with Java using Eclipse and Windows XP. I've successfully installed [I think] the 0MQ libraries as well as the Java bindings. The instructions I used to do that are located here.

Two files were built: zmq.jar and jzmq.dll. I placed the jar file in my project, which allowed the code to compile OK. I also set the java.library.path to the directory of the dll, added the perf directory to my project, and added libzmq.dll to my PATH. (All per the instructions).

I still get the following exception that I can't fix:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\jzmq\lib\jzmq.dll: Can't find dependent libraries

What other libraries is jzmq.dll dependent on? I've tried placing libzmq.dll everywhere but that didn't help. This is the code sample I'm trying to get working.

Thank you.

like image 496
Noah Avatar asked Jul 12 '12 15:07

Noah


People also ask

Is ZeroMQ TCP or UDP?

ZeroMQ sockets carry messages, like UDP, rather than a stream of bytes as TCP does. A ZeroMQ message is length-specified binary data.

How does ZeroMQ work?

ZeroMQ supports common messaging patterns (pub/sub, request/reply, client/server and others) over a variety of transports (TCP, in-process, inter-process, multicast, WebSocket and more), making inter-process messaging as simple as inter-thread messaging. This keeps your code clear, modular and extremely easy to scale.

Is ZeroMQ a message broker?

ZeroMQ (also spelled ØMQ, 0MQ or ZMQ) is an asynchronous messaging library, aimed at use in distributed or concurrent applications. It provides a message queue, but unlike message-oriented middleware, a ZeroMQ system can run without a dedicated message broker; the zero in the name is for zero broker.


2 Answers

Put any dll in Windows root or Windows System32 is urgly solution, it just pull you into Dll HELL.

What you need to do is add the ZQM binary path in the System PATH.

I compiled a 64bit ZMQ & JZMQ in a hour, and here is my folder structure:

c:\ZMQ\bin  
 ---  jzmq.dll, libzmq.dll
c:\ZMQ\lib 
 ---  ZMQ.jar

here is the step:

  1. add the binray path into system enviromennt, detail steps is control panel -- system --- advance settings , and in the pop-up tab, find the 'advance' -- 'enviroment variables' --- find the 'PATH' in the 'system vairiabls' and add C:\ZMQ\bin in the value

  2. open a dos prompt, and type 'where jzmq.dll' (I am not sure if where.exe exist in XP) to confirm if it is in the PATH now.

  3. Start the Eclipse, and open your project, right click on your project name, and select in the menu 'build path -- add external archives ' choose the C:\ZMQ\lib\zMQ.jar.

All done!

In my PC, the example runs correctly.

like image 62
ray_linn Avatar answered Oct 13 '22 00:10

ray_linn


You should copy libzmq.dll to the location pointed by java.library.path and use this:

System.loadLibrary("libzmq")

The reason is that jzmq depends on libzmq so libzmq has to be loaded first.

like image 30
John Vu Avatar answered Oct 12 '22 23:10

John Vu