简体   繁体   English

如何用Java运行ZeroMQ?

[英]How to run ZeroMQ with Java?

I'm having an issue running ZeroMQ with Java using Eclipse and Windows XP. 我在使用Eclipse和Windows XP使用Java运行ZeroMQ时遇到了问题。 I've successfully installed [I think] the 0MQ libraries as well as the Java bindings. 我已成功安装[我认为] 0MQ库以及Java绑定。 The instructions I used to do that are located here . 我以前的说明就在这里

Two files were built: zmq.jar and jzmq.dll . 构建了两个文件: zmq.jarjzmq.dll I placed the jar file in my project, which allowed the code to compile OK. 我将jar文件放在我的项目中,这允许代码编译好。 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. 我还将java.library.path设置为dll的目录,将perf目录添加到我的项目中,并将libzmq.dll添加到我的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? jzmq.dll依赖于哪些其他库? I've tried placing libzmq.dll everywhere but that didn't help. 我试过将libzmq.dll放在任何地方,但这没有帮助。 This is the code sample I'm trying to get working. 是我试图开始工作的代码示例。

Thank you. 谢谢。

Put any dll in Windows root or Windows System32 is urgly solution, it just pull you into Dll HELL. 把任何dll放在Windows root或Windows System32中都是难看的解决方案,它只是把你拉到Dll HELL。

What you need to do is add the ZQM binary path in the System PATH . 您需要做的是在系统路径中添加ZQM二进制路径。

I compiled a 64bit ZMQ & JZMQ in a hour, and here is my folder structure: 我在一小时内编译了64位ZMQ和JZMQ,这是我的文件夹结构:

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 将binray路径添加到系统环境中,详细步骤是控制面板 - 系统---提前设置,并在弹出选项卡中找到'advance' - '环境变量'---找到'PATH' 'system vairiabls'并在值中添加C:\\ ZMQ \\ bin

  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. 打开dos提示符,然后键入'where jzmq.dll'(我不确定XP中是否存在where.exe)以确认它是否在PATH中。

  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. 启动Eclipse,打开项目,右键单击项目名称,然后在菜单“构建路径 - 添加外部存档”中选择C:\\ ZMQ \\ lib \\ zMQ.jar。

All done! 全部完成!

In my PC, the example runs correctly. 在我的电脑中,该示例正确运行。

You should copy libzmq.dll to the location pointed by java.library.path and use this: 您应该将libzmq.dll复制到java.library.path指向的位置并使用:

System.loadLibrary("libzmq")

The reason is that jzmq depends on libzmq so libzmq has to be loaded first. 原因是jzmq依赖于libzmq,因此必须首先加载libzmq。

I've just encountered this problem as well. 我刚刚遇到过这个问题。 I found a workaround by putting the jzmq.dll and libzmq.dll into the System32 folder. 我通过将jzmq.dll和libzmq.dll放入System32文件夹找到了解决方法。 I don't like this as a permanent solution, but it works for the moment. 我不认为这是一个永久性的解决方案,但它暂时起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM