[zeromq-dev] ZMQ not working only when using a jar

Sabri Skhiri sabri.skhiri at gmail.com
Tue Mar 27 19:54:36 CEST 2012


I am using the zmq java binding in my project, I can launch my main class
without any problem from Eclipse, I can make run the ./local_lat.sh in the
perf directory but when I tried to launch my main class from a jar I get a
java.lang.NoClassDefFoundError: org/zeromq/ZMQ

Let me explain
I have just a main that open ZMQ.Sockets
1) On Eclipse I can run my main by just adding the
-Djava.library.path=/usr/local/lib and it starts !
2) on the jzmq directory when I test the local_lat.sh with
java -Djava.library.path=/usr/local/lib -cp
"/usr/local/share/java/zmq.jar:." local_lat  tcp:// 5 100
it works !
3)But when I want to launch the my main class from the jar I packaged it
does not work:
java -Djava.library.path=/usr/local/lib -cp
"/usr/local/share/java/zmq.jar:." -jar

Then it throws:
skhiri at sskhiri-K52JU:~/dev/RoQ/RoQ/roq-core/target$
Starting monitor process
Starting Monitor on base port 5571, 5800
Exception in thread "main" java.lang.NoClassDefFoundError: org/zeromq/ZMQ
    at org.roqmessaging.core.Monitor.<init>(Monitor.java:63)
Caused by: java.lang.ClassNotFoundException: org.zeromq.ZMQ
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)

Any clue ? Is it possible to have a different behavior if we launch a
.class directly or from a jar file ?

OS: Ubuntu 11.04
ZMQ Version: 2.1.11

Thanks for the support !

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120327/99f9060b/attachment.htm>

More information about the zeromq-dev mailing list