线程"main"中的异常java.lang.UnsatisfiedLinkError:Eclipse中的java.library.path中没有jzmq [英] Exception in thread "main" java.lang.UnsatisfiedLinkError: no jzmq in java.library.path in Eclipse

查看:415
本文介绍了线程"main"中的异常java.lang.UnsatisfiedLinkError:Eclipse中的java.library.path中没有jzmq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

导入org.zeromq.ZMQ;

Import org.zeromq.ZMQ;

-对于上述导入语句,我正在jzmq主文件夹(由ZMQ.java文件组成)中使用"org文件夹".

-For the above import statement, I am using "org folder" in jzmq master folder which consists of ZMQ.java file.

-因此,编译没有问题.当我开始运行程序时,它在下面显示了异常

-So, there is no problem with compilation. When I start running the program, It shows below exception

线程"main"中的异常java.lang.UnsatisfiedLinkError:java.library.path中没有jzmq 在java.lang.ClassLoader.loadLibrary(未知源) 在java.lang.Runtime.loadLibrary0(未知来源) 在java.lang.System.loadLibrary(未知源) 在org.zeromq.ZMQ.(ZMQ.java:41) 在server.main(Server.java:13)

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jzmq in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at org.zeromq.ZMQ.(ZMQ.java:41) at server.main(Server.java:13)

我该怎么办? 对于Java中的ZeroMQ helloworld示例,我必须下载哪些软件包以及必须使用哪些导入语句?

What should I have to do? Which packages I have to download and which import statements I have to use for the ZeroMQ helloworld example in java?

我看到许多人在某个地方使用libzmq.dll,jzmq.dll和一些jar文件来避免该异常.但是我想要一个明确的答案.

I saw that many people are using libzmq.dll, jzmq.dll and some jar files somewhere to avoid that exception. But I want a clear answer.

推荐答案

此lib(jzmq)绑定到本机库libzmq. 如果您不使用libzmq的功能(例如ipc),则最好使用完整的Java实现- jeromq ( jeromq git ).它具有几乎相同的功能.

This lib (jzmq) is binding to the native library libzmq. If you don't use features of libzmq (ipc for example) you'd better to use full java implementation - jeromq (mvnrepo, jeromq git). It has almost the same functionality.

否则,如果需要jzmq,则必须正确编译. 这是我在Windows x64上编译它的方式:

Otherwise if you need jzmq, you have to compile it properly. This is the way i compiled it on windows x64:

要构建该库,您需要IDE Visual Studio 2010或更高版本.在此示例中,我使用了2013版本.所有工作都在目录C:\zmq中进行(例如).

To build the library you need IDE Visual Studio 2010 or higher. In this example i used 2013 version. All work is performed in the directory C:\zmq (for example).

  1. 获取zeromq,jzmq和libsodium-1.0.10源.
  2. 将zeromq目录的全部内容复制到C:\zmq.
  3. 创建目录C:\zmq\java.
  4. 将jzmq目录的全部内容复制到C:\zmq\java.
  5. 创建目录C:\zmq\libsodiumC:\zmq\libsodium
  6. 复制到C:\zmq\libsodium\bi n libsodium-1.0.10-msvc\Win32libsodium-1.0.10-msvc\x64目录.
  7. 创建目录C:\zmq\libsodium\src.
  8. 复制到C:\zmq\libsodium\src directory libsodium-1.0.10-msvc \ include.
  1. Get the zeromq, jzmq and libsodium-1.0.10 sources.
  2. Copy the entire contents of zeromq directory to C:\zmq.
  3. Create a directory C:\zmq\java.
  4. Copy the entire contents of jzmq directory to C:\zmq\java.
  5. Create a directories C:\zmq\libsodium and C:\zmq\libsodium
  6. Copy to C:\zmq\libsodium\bin libsodium-1.0.10-msvc\Win32 and libsodium-1.0.10-msvc\x64 directories.
  7. Create a directory C:\zmq\libsodium\src.
  8. Copy to C:\zmq\libsodium\src directory libsodium-1.0.10-msvc\include.

Zeromq.

在Visual Studio中,从目录C:\zmq\builds\msvc中打开相应的zeromq解决方案文件.

Open in Visual Studio the appropriate zeromq solution file from the directory C:\zmq\builds\msvc.

打开配置管理器.主动配置解决方案-选择DynRelease.主动解决方案平台-选择x64.

Open configuration manager. Active configuration solutions - choose DynRelease. Active solution platform - choose x64.

打开项目属性页,转到配置属性-C/C ++-常规",检查包含文件目录的路径.

Open project properties page, go to Configuration Properties - C/C++ - General, check paths for include files directories.

然后选择链接器-常规,并检查库目录的路径.

Then select linker - General, and check paths for the libraries directories.

在配置文件C:\zmq\builds\msvc\vs2013\libsodium.import.props中,此部分中的正确路径.

In the configuration file C:\zmq\builds\msvc\vs2013\libsodium.import.props correct path in the section.

然后将其建立,如果一切正确,您将在C:\zmq\bin\x64\Release\v120\dynamic目录中获得dll.如果不是,请-检查日志,进行更改并重新构建.

Then buid it, if all was correct you will get dlls in C:\zmq\bin\x64\Release\v120\dynamic directory. If it wasn't - check out logs, make changes and rebuild it.

Jzmq.

现在从目录C:\zmq\java\builds\msvc\

以及在zeromq项目中打开配置管理器,然后选择Release和x64平台.

As well as in zeromq project open configuration manager and select Release and x64 platform.

打开项目属性页,转到配置属性-VC ++目录",并检查JDK的安装路径是否正确. 您将看到类似以下的内容:

Open project properties page, go to Configuration Properties - VC ++ Directories and check that path where your JDK was installed is correct. You will se there something like this:

..\..\..\..\include;C:\Program Files\Java\jdk1.7.0_71\include;C:\Program
Files\Java\jdk1.7.0_71\include\win32;$(IncludePath)

还要检查库目录"(忘记其名称)路径是否包含具有内置zeromq库的目录的路径. 看起来像这样:

Also check that Library Catalogues (forgot its name) path include path to the directory with built zeromq libs. It will look like this:

..\..\..\..\bin\x64\Release\v120\dynamic;$(LibraryPath)

在属性页上,转到配置属性-组装事件-组装前的事件",然后检查命令提示符"属性(首先检查复制命令中文件的路径). 看起来像这样:

On the properties page, go to Configuration Properties - assembly events - event before assembly and check property "Command Prompt" (first of all check paths to files in copy command). It will look like this:

copy ..\config.hpp "..\..\..\src\main\c++\"

然后buid jzmq,如果一切正确,您将在C:\zmq\java\lib中获得文件.

Then buid jzmq, if all was correct you will get files in C:\zmq\java\lib.

如果不是,请-检查日志,进行更改并重新构建.

If it wasn't - check out logs, make changes and rebuild it.

C:\zmq中,您只需要bin java\lib目录,其余目录可以删除.

In the C:\zmq you need only bin java\lib directories, the rest can be removed.

bin\x64\Release\v120\dynamic的路径添加到PATH并使用-Djava.library.path="path_to_java\lib"

Add to PATH the path to bin\x64\Release\v120\dynamic and run you java app with -Djava.library.path="path_to_java\lib"

这篇关于线程"main"中的异常java.lang.UnsatisfiedLinkError:Eclipse中的java.library.path中没有jzmq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆