eclipse 如何使用 Java 运行 ZeroMQ?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11455588/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:33:48  来源:igfitidea点击:

How to run ZeroMQ with Java?

javaeclipsezeromq

提问by Noah

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.

我在使用 Eclipse 和 Windows XP 使用 Java 运行 ZeroMQ 时遇到问题。我已经成功安装了 [我认为] 0MQ 库以及 Java 绑定。我曾经这样做的说明位于此处

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

构建了两个文件:zmq.jarjzmq.dll。我将jar文件放在我的项目中,这使得代码编译OK。我还将java.library.path设置为dll 的目录,将 perf 目录添加到我的项目中,并将 libzmq.dll 添加到我的 PATH。(全部按照说明)。

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

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. Thisis the code sample I'm trying to get working.

jzmq.dll 依赖于哪些其他库?我试过将 libzmq.dll 放在任何地方,但这没有帮助。是我试图开始工作的代码示例。

Thank you.

谢谢你。

采纳答案by ray_linn

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

将任何 dll 放在 Windows 根目录或 Windows System32 中都是非常糟糕的解决方案,它只会将您拉入 Dll HELL。

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

您需要做的是在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

  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.

  1. 将binray路径添加到系统环境中,详细步骤是控制面板——系统——高级设置,在弹出的选项卡中,找到“高级”——“环境变量”——找到“PATH” “系统变量”并在值中添加 C:\ZMQ\bin

  2. 打开 dos 提示符,然后输入“where jzmq.dll”(我不确定 XP 中是否存在 where.exe)以确认它现在是否在 PATH 中。

  3. 启动Eclipse,打开你的项目,右击你的项目名称,在菜单'build path -- add external archives'中选择C:\ZMQ\lib\zMQ.jar。

All done!

全部完成!

In my PC, the example runs correctly.

在我的 PC 中,该示例运行正常。

回答by John Vu

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。

回答by ct5098

I've just encountered this problem as well. I found a workaround by putting the jzmq.dll and libzmq.dll into the System32 folder. I don't like this as a permanent solution, but it works for the moment.

我也刚遇到这个问题。我通过将 jzmq.dll 和 libzmq.dll 放入 System32 文件夹中找到了一种解决方法。我不喜欢这是一个永久的解决方案,但它目前有效。