We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I would like to use JeroMQ (pure Java zeroMQ) but the problem is that I know NOTHING AT ALL/ZERO/NULL about Java and don't know how to include and use it in Processing.
These are the steps I followed:
1) clone https://github.com/zeromq/jeromq from src/main/java/zmq
2) compile the package with javac -d ./build *.java
and then jar cvf zmq.jar *
3) drop zmq.jar on the editor (code/zmq.jar is created)
Then I picked up a zeroMQ Java example from http://zguide.zeromq.org/java:psenvsub:
import org.zeromq.ZMQ;
import org.zeromq.ZMQ.Context;
import org.zeromq.ZMQ.Socket;
/**
* Pubsub envelope subscriber
*/
public class psenvsub {
public static void main (String[] args) {
// Prepare our context and subscriber
Context context = ZMQ.context(1);
Socket subscriber = context.socket(ZMQ.SUB);
subscriber.connect("tcp://localhost:5563");
subscriber.subscribe("B".getBytes());
while (!Thread.currentThread ().isInterrupted ()) {
// Read envelope with address
String address = subscriber.recvStr ();
// Read message contents
String contents = subscriber.recvStr ();
System.out.println(address + " : " + contents);
}
subscriber.close ();
context.term ();
}
}
and rewrote it as:
import org.zeromq.ZMQ;
import org.zeromq.ZMQ.Context;
import org.zeromq.ZMQ.Socket;
void setup() {
Context context=ZMQ.context(1);
Socket subscriber = context.socket(ZMQ.SUB);
subscriber.connect("tcp://localhost:5556");
subscriber.subscribe("B".getBytes());
while (!Thread.currentThread ().isInterrupted ()) {
// Read envelope with address
String address = subscriber.recvStr ();
// Read message contents
String contents = subscriber.recvStr ();
System.out.println(address + " : " + contents);
}
subscriber.close ();
context.term ();
}
void draw() {
}
There are no errors at all. Changing object names or removing an import an error message is promptly shown.
The code executes showing me the standard empty 100x100 window, but it doesn't work.
I read on the editor console: No library found for org.zeromq.ZMQ (twice, so I assume one is for Context, the other for Socket)
I imagine it has to do with some paths or package structure.
About /META-INF/MANIFEST.MF, its content is:
Manifest-Version: 1.0
Created-By: 1.8.0_121 (Oracle Corporation)
Any idea?
Answers
Solution found. This works: