[zeromq-dev] Issue with maven commands and running java programs form zmq.jav

Joshua Foster jhawk28 at gmail.com
Fri Dec 2 17:01:14 CET 2011


Try this:

java -Djava.library.path=/usr/local/lib -cp jzmq-1.0.0.jar:. hwclient

You need to include the local directory if you are running your code. If you are running within eclipse, you need to add -Djava.library.path=/usr/local/lib to the vm parameters and the jzmq-1.0.0.jar as a dependent library.

Joshua

On Dec 2, 2011, at 12:32 AM, Mark Obsniuk wrote:

> I'm running OS X. I had to install brew install pkg-config to run the
> java binding. Below is a list of commands used to setup environment.
> 
>> git clone https://github.com/zeromq/zeromq2-1.git
> 
>> cd zeromq2-1
>> ./autogen.sh
>> ./configure
>> make all
>> make install
>> make check
> 
>> git clone https://github.com/zeromq/czmq.git
>> cd zeromq2-1
>> ./autogen.sh
>> ./configure
>> make all
>> make install
>> make check
> 
>> https://github.com/zeromq/jzmq.git
>> cd zeromq2-1
>> ./autogen.sh
>> ./configure
>> make all
>> make install
> 
> After these steps I am able to build and run zguide examples for C. And as
> indicated make check runs successfully after building the C code.
> 
> 1) command line running
> 
> Now moving to running java applications. I first created an eclipse
> project based upon maven settings I found online. I added
> -Djava.library.path=/usr/local/lib to run configuration settings for VM
> arguments. I can then run code from within eclipse. I haven't found anyway
> to do the same from the command line. I've tried everything I can think of
> such as
> 
> java -cp /usr/local/share/java/zmq.jar hwclient
> java -cp jzmq-1.0.0.jar hwclient
> java -Djava.library.path=/usr/local/lib -cp jzmq-1.0.0.jar hwclient
> 
> I always get this 
> 
> Exception in thread "main" java.lang.NoClassDefFoundError: hwclient
> Caused by: java.lang.ClassNotFoundException: hwclient
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> 
> 
> 2) maven building of jzmq
> 
> 
> 
> I had a scm error in which I had to remove the maven build number from the
> pom file. (Suggested by Karl Ostendorf)
> Then I added a build option and it would compile and run unit tests.
> Problem is I get this error on almost every test.
> 
> ---------------------------------------------------------------------------
> ----
> Test set: org.zeromq.ZMQForwarderTest
> ---------------------------------------------------------------------------
> ----
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.006 sec
> <<< FAILURE!
> testQueue(org.zeromq.ZMQForwarderTest)  Time elapsed: 0.005 sec  <<< ERROR!
> java.lang.UnsatisfiedLinkError: no jzmq in java.library.path
> 	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758)
> 	at java.lang.Runtime.loadLibrary0(Runtime.java:823)
> 	at java.lang.System.loadLibrary(System.java:1045)
> 	at org.zeromq.ZMQ.<clinit>(ZMQ.java:34)
> 	at org.zeromq.ZMQForwarderTest.testQueue(ZMQForwarderTest.java:11)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3
> 9)
> 	at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
> l.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod
> .java:44)
> 	at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.
> java:15)
> 	at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.j
> ava:41)
> 	at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.ja
> va:20)
> 	at 
> org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunn
> er.java:79)
> 	at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.ja
> va:71)
> 	at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.ja
> va:49)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> 	at 
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:3
> 5)
> 	at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provid
> er.java:146)
> 	at 
> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:
> 97)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3
> 9)
> 	at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
> l.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at 
> org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(Pr
> oviderFactory.java:103)
> 	at $Proxy0.invoke(Unknown Source)
> 	at 
> org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireSta
> rter.java:145)
> 	at 
> org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(Surefir
> eStarter.java:87)
> 	at 
> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
> 
> I noticed that my eclipse project I created above has defined the library
> path but the same thing is missing here. Or is defined differently and
> possible enough that it won't work on OS X.
> 
> This is one of the settings in my working java project using zmq.jar
> created from make all; make install
> 
>   <dependencies>
> <dependency>
> <groupId>org.zeromq</groupId>
> <artifactId>jzmq</artifactId>
> <version>2.1.0-SNAPSHOT</version>
> <scope>system</scope>
> <systemPath>/usr/loca/share/java/zmq.jar</systemPath>
> </dependency>
> </dependencies>
> 
> 
> I commented out all the tests that failed and built the jzmq jar file to
> see if that would run on the command line. (If your wondering how I have a
> jzmq jar file if I can't get past this step.)
> 
> This may all improve on the next release in a few weeks but in the mean
> time I need to try and get through these couple of hurdles.
> 
> Any assistance is greatly appreciated.
> 
> Thanks,
> 
> Mark
> 
> 
> 
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev




More information about the zeromq-dev mailing list