Noah Noah - 1 year ago 274
Java Question

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.

Answer Source

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:

 ---  jzmq.dll, libzmq.dll
 ---  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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download