jzmq java,线程“ main”中的异常java.lang.UnsatisfiedLinkError:Eclipse中的java.library.path中没有jzmq...

Import org.zeromq.ZMQ;

-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

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)

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?

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.

解决方案

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.

Otherwise if you need jzmq, you have to compile it properly.

This is the way i compiled it on windows x64:

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).

Get the zeromq, jzmq and libsodium-1.0.10 sources.

Copy the entire contents of zeromq directory to C:\zmq.

Create a directory C:\zmq\java.

Copy the entire contents of jzmq directory to C:\zmq\java.

Create a directories C:\zmq\libsodium and C:\zmq\libsodium

Copy to C:\zmq\libsodium\bin libsodium-1.0.10-msvc\Win32 and

libsodium-1.0.10-msvc\x64 directories.

Create a directory C:\zmq\libsodium\src.

Copy to C:\zmq\libsodium\src directory

libsodium-1.0.10-msvc\include.

Zeromq.

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

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

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.

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

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.

Now open the appropriate jzmq solution file from the directory C:\zmq\java\builds\msvc\

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

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)

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++\"

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.

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值