0

I want to run zmq with java. I had tried to do it like in a question

I compiled project https://github.com/zeromq/libzmq then https://github.com/zeromq/jzmq

After all run my program with argument -Djava.library.path=C:\zmq\jzmq\jzmq-jni\builds\msvc\x64\Release\;C:\zmq\libzmq\bin\x64\Release\v141\dynamic

import org.zeromq.ZMQ;

public class TestZMQ {

    public static void main(String[] args) throws Exception {
        ZMQ.Context context = ZMQ.context(1);
    }
}

As a result I have exception

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\zmq\jzmq\jzmq-jni\builds\msvc\x64\Release\jzmq.dll: Can't find dependent libraries
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at org.zeromq.ZMQ.<clinit>(ZMQ.java:40)
    at TestZMQ.main(TestZMQ.java:8)

Dependency walker shows multiple errors. People says it appear because of walker own, not library. enter image description here

Thanks for any help.

Community
  • 1
  • 1

1 Answers1

1

There is the problem with java.library.path in windows. Normally it takes system var Path and put it into java.library.path. When I set -Djava.library.path=myLybraryPath, it became myLybraryPath, but you need something like this ${java.library.path};myLybraryPathotherwise your application can't find windows libs.

I've found the solution of this problem by adding my library in Path's system variable. There is another similar solution

set PATH=%PATH%;myLybraryPath

PS: There is no the same problem in linux. It's just windows' jvm realization problem.