[zeromq-dev] Java Binding
Glenn Lemoine
glemoine44 at msn.com
Wed Jan 18 15:00:37 CET 2012
Guys,
I've successfully downloaded and compiled libzmq.dll as well as jzmq.dll in VS2008 on Windows XP 32bit. I've xcopied the libraries as well as the jars to C:\zmq\bin and C:\zmq\java respectively. I've added java.library.path=.;C:\zmq\java to my system variables. I've added ;C:\zmq\java to my classpath and I've added C:\zmq\bin to my Path. After several iterations on the command line, it seems that the zmq.jar cannot locate jzmq.dll as i get the following exception:
C:\Devel\zmq\zeromq-jzmq-4bdf011\perf>java local_lat tcp://127.0.0.1:5555 1 100
Exception in thread "main" java.lang.NoClassDefFoundError: org/zeromq/ZMQ
at local_lat.main(local_lat.java:36)
Caused by: java.lang.ClassNotFoundException: org.zeromq.ZMQ
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
I then tried copying the .dlls (libzmq,jzmq) into the C:\Windows\System32 directory as well as to the C:\Devel\zmq\zeromq-jzmq-4bdf011\perf directory to no avail. On the latest attempt I opened up the project in eclipse and added the .dll as a native library. On this iteration, the zmq.jar successfully found the jzmq.dll as evidenced by successfully creating a context:
ZMQ.Context ctx = ZMQ.context (1);
ZMQ.Socket s = ctx.socket (ZMQ.REP);
// Add your socket options here.
// For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
s.bind (bindTo);
Unfortunately, the thread dies when it reaches
for (int i = 0; i != roundtripCount; i++) {
byte [] data = s.recv (0);
on ZMQ.context.recieve with no exception.
I'd appreciate help with the following two problems
1) Correctly declaring system and environment variables to run jzmq from the command line.
2) Diagnosing why the thread is dying when it reaches s.recv(0) (I haven't looked as of yet, but my hunch is that s.recv calls into libzmq.dll and i currently have it configured incorrectly.
Many Thanks
G
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120118/110f3718/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: classpath.png
Type: image/png
Size: 2275 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120118/110f3718/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JAVA_HOME.png
Type: image/png
Size: 2213 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120118/110f3718/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: path.png
Type: image/png
Size: 2224 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120118/110f3718/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zmq_bin.png
Type: image/png
Size: 21738 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120118/110f3718/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: java.library.path.png
Type: image/png
Size: 2124 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120118/110f3718/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eclipse_config.png
Type: image/png
Size: 16403 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120118/110f3718/attachment-0005.png>
More information about the zeromq-dev
mailing list