Including libraries generating jar and executing with java -jar on Intellij - java

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.

Related

java -jar and java.lang.NoClassDefFoundError

root#raspberrypi:/home/pi/java/src/driver# make run
java -jar Core.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/pi4j/io/gpio/GpioFactory
I used and altered a makefile that I'm sure of is correct, but let me include it as well:
http://pastebin.com/nzenp2E8
What do I do wrong?
Edit:
I know the imports are correct
And I've already tried like giving java -jar Core.jar a classpath in several ways, but the same error keeps popping up.
Create jar with -e option [specify application entry point for stand-alone application bundled into an executable jar file]:
jar cfe Core.jar pract2.Solution pract2\*
Here pract2.Solution is main class.
Run using
java -jar Core.jar
Or
java -cp .;Core.jar -jar Core.jar

Java Path zeromq setting

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

java.lang.UnsatisfiedLinkError: no lwjgl in java.libary.path at java run

I'm trying to run my java program with 2 external libraries ( lwjgl.jar and slick-util.jar )
compiling worked fine
but when i run with the following command:
java -cp bin;.;lib/lwjgl.jar;lib/slick-util.jar; Game
I get the following Exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
Okay my current command is:
java -cp bin;.;lib/lwjgl.jar;lib/slick-util.jar;
-Djava.library.path="D:\dev\LWJGL\lwjgl-2.9.0\native\windows\lwjgl.dll"
Change that to:
java -cp bin;.;lib/lwjgl.jar;lib/slick-util.jar;
-Djava.library.path="D:\dev\LWJGL\lwjgl-2.9.0\native\windows"
The -Djava.library.path is a search path; i.e. a list of places to look for the lwjgl.dll file.

How to execute project with JOGL library?

I'm developing Java project with JOGL, but when I'm trying to execute my project I'll got the following message:
Catched FileNotFoundException: E:\Eclipse\Projects\FuzzyProject\lib\jogl2-rc10\gluegen-natives-windows-i586.jar (Can't find file), while TempJarCache.bootstrapNativeLib() of jar:file:/E:/Eclipse/Projects/FuzzyProject/lib/jogl2-rc10/gluegen-natives-windows-i586.jar!/ (file:/E:/Eclipse/Projects/FuzzyProject/lib/jogl2-rc10/ + gluegen-natives-windows-i586.jar)
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path
How can I fix this problem?
From console java -Djava.library.path=<path to native library> -jar (if jar) <name of jar or class>
From code just System.loadLibrary(<path to native library>)
From Eclipse: Run Configuration -> Arguments -> VM Argiments->-Djava.library.path=<path to native library>
I assume you're running this from eclipse and on a windows machine, so have a look here: I installed JOGL but why wont Eclipse recognize my hello world program?
For gluegen, have a look here: java.lang.UnsatisfiedLinkError: no gluegen-rt in java.library.path RCP Application

Exception in thread "main" java.lang.UnsatisfiedLinkError: no Terminal in java.library.path

I was trying to run the CHARVA Tutorial thru Eclipse after setting up the JAR,
but I receive
Exception in thread "main" java.lang.UnsatisfiedLinkError: no Terminal in java.library.path
in the console. Any clue on how to fix this up?
As Dave said, Charva requires a native library called Terminal to run. As far as I remember, it is included in the binary distribution for Charva.
Eclipse-specific instructions: In your project properties, select Java Build Path, then Libraries. Locate the jar and set the Native library location to the path where the Terminal library is.

Categories

Resources