I am trying to run Zeromq java program in windows 10 OS. To set up the environment I tried to do the following.
1) Download and install the java library for ZMQ from here http://zeromq.org/distro:microsoft-windows.
2) Add the path in the environmental variables.
3) Tried to run the simple Hello World code from zguide.
Server:
import org.zeromq.ZMQ;
public class Hwserver {
public static void main(String[] args) throws Exception {
ZMQ.Context context = ZMQ.context(1);
// Socket to talk to clients
ZMQ.Socket responder = context.socket(ZMQ.REP);
responder.bind("tcp://*:5555");
while (!Thread.currentThread().isInterrupted()) {
// Wait for next request from the client
byte[] request = responder.recv(0);
System.out.println("Received " + new String (request));
// Do some 'work'
Thread.sleep(1000);
// Send reply back to client
String reply = "World";
responder.send(reply.getBytes(), 0);
}
responder.close();
context.term();
}
}
Client:
import org.zeromq.ZMQ;
public class Hwclient {
public static void main(String[] args) {
ZMQ.Context context = ZMQ.context(1);
// Socket to talk to server
System.out.println("Connecting to hello world server…");
ZMQ.Socket requester = context.socket(ZMQ.REQ);
requester.connect("tcp://localhost:5555");
for (int requestNbr = 0; requestNbr != 10; requestNbr++) {
String request = "Hello";
System.out.println("Sending Hello " + requestNbr);
requester.send(request.getBytes(), 0);
byte[] reply = requester.recv(0);
System.out.println("Received " + new String(reply) + " " + requestNbr);
}
requester.close();
context.term();
}
}
When I tried to compile the server I got the following error.
error: cannot find symbol import org.zeromq.ZMQ;
After that I tried to install the library manually. I did the following.
1) Downloaded and unzipped Libzmq-master and jzmq-master from Github.
2) Using Visual Studio 2017 tried to build libzmq.sln & msvc.sln from the directory here
libzmq - libzmq-master\builds\deprecated-msvc\vs2017\libzmq.sln
jzmq - jzmq-master\jzmq-jni\builds\msvc\msvc.sln
But couldn't able to build it. Finding several errors. For example:
libzmq - #error: None of the ZMQ_IOTHREAD_POLLER_USE_* macros defined (compiling source file ........\src\client.cpp) libzmq c:\users\shiha\downloads\libzmq-master\src\poller.hpp
jzmq - Cannot open include file: 'zmq.h': No such file or directory
I am not getting what I am doing wrong. I have followed the guide provided in zeromq.org and also searched for the similar problem. But couldn't able to find the solution.