I am using MAC OSX
I already follow the instruction on 0mq official site to install
when i compile it , i dont get any error.
But when i run the following command
java -classpath /Users/john/jzmq/ -cp $(lein classpath) storm.starter.WordCountTopology
I got the following error.
java.lang.UnsatisfiedLinkError: no jzmq in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1878)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1087)
at org.zeromq.ZMQ.<clinit>(ZMQ.java:34)
at storm.starter.spout.RandomSentenceSpout.nextTuple(RandomSentenceSpout.java:39)
at backtype.storm.daemon.executor$fn__3985$fn__3997$fn__4026.invoke(executor.clj:502)
at backtype.storm.util$async_loop$fn__465.invoke(util.clj:377)
at clojure.lang.AFn.run(AFn.java:24)
at java.lang.Thread.run(Thread.java:724)
My setting
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home
I also have zmq.jar under
/usr/local/lib and
/usr/local/share/java
I read through all the google search I can found. Still no crew why my one is not working
In addition to setting the JAR classpath, you need to specify where the jzmq .so library files reside. Did you build zmq, libzmq, and jzmq exactly as described in the directions? If so, you should see the .so library files in /usr/local/lib and zmq.jar in /usr/local/share/java, confirm that, then logout/login based on this, then try this:
java -Djava.library.path=/usr/local/lib -cp "/usr/local/share/java/zmq.jar:/Users/john/jzmq/<your jar here>" storm.starteer.WordCountTopology
Hope it helps
Related
I am trying to install Mooshak which is distributed as a .jar installer. When I run the file, it gives me the following error about a missing class:
ifinlay#mooshak:~$ sudo java -jar MooshakInstaller.jar -cui
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/ArchiveException
at pt.up.fc.dcc.mooshak.installer.Installer.<init>(Installer.java:26)
at pt.up.fc.dcc.mooshak.installer.Installer.main(Installer.java:52)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.compress.archivers.ArchiveException
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:436)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 7 more
So it can't find the org/apache/commons/compress/archivers/ArchiveException class. But I have installed this library and have the following in my CLASSPATH:
ifinlay#mooshak:~$ echo $CLASSPATH
.:/usr/share/maven-repo/org/apache/commons/commons-compress/1.18/commons-compress-1.18.jar
And this .jar file in the CLASSPATH does seem to contain the class in question:
ifinlay#mooshak:~$ jar tvf /usr/share/maven-repo/org/apache/commons/commons-compress/1.18/commons-compress-1.18.jar
# ... other classes edited out
722 Fri Mar 01 16:57:28 UTC 2019 org/apache/commons/compress/archivers/ArchiveException.class
# ... other classes edit out
So why can Java not find this class when it does seem to be in the path? Any help would be so awesome, I'm really scratching my head at this.
Thanks for reading!
EDIT: The Manifest file for the .jar looks like this:
Manifest-Version: 1.0
Rsrc-Class-Path: ./ junit.jar org.hamcrest.core_1.3.0.v201303031735.ja
r commons-compress-1.12.jar BrowserLauncher2-all-1_3.jar
Class-Path: .
Rsrc-Main-Class: pt.up.fc.dcc.mooshak.installer.Installer
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader
So this seems to imply that the commons-compress-1.12.jar file should just be placed in the same directory as the installer. This doesn't seem to work though...
Why is Java not finding classes that are in the CLASSPATH?
Short answer: because they are NOT on the actual classpath.
Long answer:
There is either something wrong with the installer, or you are not running it correctly / as it is designed to be run.
When you run a java like this with a -jar option:
java -jar MooshakInstaller.jar -cui
it will ignore the CLASSPATH variable, and any -cp arguments that you add. That explains why Java is not finding classes in the commons-compress-1.18.jar JAR file on your (assumed) classpath.
This means one of the following:
The MooshakInstaller.jar installer is missing a dependency; i.e. it is broken. (I doubt this is the case. They would have spotted this.)
The MooshakInstaller.jar installer is not designed to be run as an executable JAR.
The MooshakInstaller.jar installer is expecting to find the dependency in some location relative to the location of the JAR file. (See if there is a "Class Path" attribute in the JAR's manifest file.)
I would also note that when you run this:
sudo java -jar MooshakInstaller.jar -cui
the value of the CLASSPATH environment variable will probably not be passed through to the root process. Check the manual entry for sudo. This is not the actual problem here ... because the CLASSPATH variable is being ignored anyway, due to the -jar option.
UPDATE
It looks like you simply didn't follow the installation instructions:
To install Mooshak you must execute the following commands. Make sure your system has all requirements. Note that you must have root privileges
% tar xzf mooshak-version.tgz
% cd mooshak-version
% su
# ./install
That's not what you did, and I strongly suspect that what you actually did is not equivalent to the above.
(I'm not going to investigate this further, because the download procedure requires me to give them all sorts of personal details. No way Jose!)
This answer is based on the new information you provided. It changes things.
First of all, what I said about CLASSPATH and -jar remains true.
However, it turns out that the Mooshak 2 installer is an executable JAR that uses a "jar in jar" loader.
The main class is org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.
The manifest specifies that the classpath for the installer should include these nested JARs which are part of the installer JAR:
junit.jar
org.hamcrest.core_1.3.0.v201303031735.jar
commons-compress-1.12.jar
BrowserLauncher2-all-1_3.jar
The JarRsrcLoader entrypoint classes should then set up classloaders for the above JARs, and then start the installer.
And it should all just work.
I do see one strange thing though. The manifest has commons-compress-1.12.jar, but you seem to be trying to use commons-compress-1.18.jar.
You said:
So this seems to imply that the commons-compress-1.12.jar file should just be placed in the same directory as the installer.
I don't read it that way, but I will see if I can find the documentation.
UPDATE: nope. I couldn't find the documentation, but it seems from the JarRsrcLoader source code, that it doesn't work that way.
But I did find a clue. In the current version of JarRsrcLoader there is separate code for Java 8 and Java 9+. So, if the Mooshak 2.0 installer uses an older version of JarRsrcLoader, AND you are trying to install with Java 9 or later, then it is possible that it won't work.
So, make sure that you use Java 8 ... like the requirements say.
However, what you are apparently trying to do here is to use a different version of the compress library. The better way to do this is to set up your own build tree for Mooshak:
... checkout the full source code with svn checkout https://svn.dcc.fc.up.pt/projects/Mooshak/Mooshak/
Then modify the dependencies and build / install as per the instructions that I presume are in the tree.
I've been trying to execute a jar file through command line but I'm still getting an exception that I'm missing a library even though it was properly added as it's shown here. The library that I'm trying to run my code with is the opencv's lib. I'm able to run my app from intellij and generate a jar artifact that I can see the jar grows in size when I add the opencv lib but when I try to run the app from the command line with "java -jar Test.jar" I get the message that I'm missing the opencv library.
rinaldi#rinaldi-work:~/Projects/Test/out/artifacts/Test_jar$ java -jar Test.jar Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java310 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at HelloWorld.<clinit>(HelloWorld.java:14)
at Main.main(Main.java:4)
I've also tried to run the app adding the path to the opencv's library:
:~/Projects/Test/out/production/Test$ java -cp .:~/Sources/opencv-master/build/bin/opencv-310.jar Main
And another attempt because opencv needs not only it's jar but also the /opencv-master/build/lib/ directory:
:~/Projects/Test/src$ java -cp :/home/rinaldi/Sources/opencv-master/build/bin/opencv-310.jar:/home/rinaldi/Sources/opencv-master/build/lib/ Main
Below are the images from intellij's configuration.
I had to add the library this way:
java -jar -Djava.library.path=/home/rinaldi/Sources/opencv-master/build/lib test.jar
Hope this helps someone.
I am attempting to install Hibernate3 onto my linux server but I'm having a hard time figuring out what to do to get it to work. I have tried the following:
copy required jars into a folder and called the folder via "java -classpath etc." and got
java -classpath /home/mcmaster/javalibs/* -jar craftbukkit.jar
Error: Could not find or load main class .home.mcmaster.javalibs.dom4j-1.6.1.jar
load the java command while calling only the core hibernate which resulted in normal class not found error
on a whim installed to system java lib location with no affect
used apt-get to install libhibernate3-java with no change
I have attempted to export $CLASSPATH=~/javalibs which has all the required jars
I'm literally pulling my hair out as an intermediate java user trying to learn some more advanced things(to me).
Here's the error I'm getting when trying to call the Session Class:
Caused by: java.lang.ClassNotFoundException: org.hibernate.Session
Looks like you forgot the quotation marks. Try
java -classpath '.:/home/mcmaster/javalibs/*' -jar craftbukkit.jar (as seen on wikipedia).
EDIT: I am guessing that craftbukkit.jar is executable.
I want to call a C program from Java program using JNI in linux ubuntu.
I am new to this and I have tried the sample program given in http://www.ibm.com/developerworks/java/tutorials/j-jni/section2.html
. I have already created the .java, .h , .c and .so files. But when i tried to run the program I am getting the following error.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no Sample1 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at Sample1.main(Sample1.java:13)
This exception is indicating that the .so is not available to the JVM.
Adding the directory where the .so exists to the LD_LIBRARY_PATH will resolve this. If the .so depends on other .so libraries the directories where these .so exist will also need added to LD_LIBRARY_PATH.
I've just tried to get the same sample to work on my CentOS and got the same error as you. As already answered, JVM failed to find the so file needed. I succeeded to get it to work by following the steps below using gcc:
$ javac Sample1.java
$ javah Sample1
$ # Include paths must also be specified using -I option in the following gcc command line!
$ gcc -shared -I...snip... Sample1.c -o libSample1.so
$ # Library path for libSample1.so must also be specified!
$ java -Djava.library.path=...path/to/libSample1.so... Sample1
If you omit the "lib" prefix of the shared library, JVM fails to find it for some reason.
I don't know why. I am not familiar with the naming convention of shared libraries in Linux.
I hope this post could help.
I am having some trouble setting up my environment in Eclipse for ImageMagick via JMagick in OS X. I have no problems using the ImageMagick command line tools (display, convert, etc.) after installing, but am unable to set up JMagick with a Java project in Eclipse.
Steps taken:
Downloaded JMagick 6.4.0
Generated jar and libs through make process in the INSTALL document
Copied libJMagick.so and libJMagick-6.4.0.so from lib to /usr/lib/java
Added JMagick.jar to build path
Linked /usr/lib/java directory to JMagick.jar native source, recommended in the solution posted by trigoman at the following url: JMagick Error when trying to load a file - UnsatisfiedLink
Created sample class that accesses JMagick and attempted to run in Eclipse. Exception reported:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no JMagick
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
example.ImageRender.main(ImageRender.java:10)
Does anyone have any ideas what might be the underlying problem is?
edit: see my comment below about using im4java instead of JMagick.
I was having the same problem, but just got it working by following these sparse instructions:
http://wesleyli.blog.com/2011/09/01/install-jmagick-on-mac/
But note there's a couple typos; looks like Lion auto-correct problems.
So what I did was:
svn co https://jmagick.svn.sourceforge.net/svnroot/jmagick jmagick
cd jmagick/trunk
./configure --with-java-home=/System/Library/Frameworks/JavaVM.framework/Versions/Current --with-magick-home=/usr/local/jmagick
sudo make all & sudo make install
sudo ln -s /usr/local/lib/libJMagick-6.5.7.so /Library/Java/Extensions/libJMagick.jnilib
And now it works for me. :)