I have build my project using OpenCV. When I run my project through netbeans it runs fine.. but when I create its jar file via Clean and Build it doesn't open.
it displays a message in output screen when it is build that is..
To run this application from the command line without Ant, try:
java -jar "C:\Users\Rafi Abro\Documents\NetBeansProjects\WebCam\dist\WebCam.jar"
I also tried to open my project through this command..
java -jar WebCam.jar
but it displayed error below:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java2410 in
java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at javaanpr.Main.main(Main.java:154)
please can anyone help me through out this problem..
Thanks
This is because you have included VM option path in netbeans. and Netbeans Automatically calls it whenever it is executed.
now when you are trying to run command. i.e.
java -jar WebCam.jar
there is not path defined in command, thatsy you are getting that error..
try this command:
java -Djava.library.path="C:\OpenCV\opencv\build\java\x86" -jar WebCam.jar
hope this will help you.!
Related
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 got a programm which is working on my ide (Eclipse Luna Service Release 2 (4.4.2)). Now i want to execute it without Eclipse to be able to run it on others computer.
I exported it from eclipse using export projet into a jar file, a specified this manifest:
Manifest-Version: 1.0
Main-class: RecupPhoto
Class-path: opencv-300.jar
Both files, RecupPhoto.jar and opencv-300.jar are in the same folder, i already checked the java path, the jre and jdk.
My problem is when i execute:
java -jar RecupPhoto.jar
with a .bat file inside the jar folder i got this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java300 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at Ihm.<init>(Ihm.java:89)
at RecupPhoto.main(RecupPhoto.java:10)
I'm not expert on errors etc but i understand that there is an error with "opencv_java300", but i don't understand this error because i didn't get this import with a "java" in the middle of the name.
Here is the loadlibrary from the error, in case it could help:
System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
(core is a package from opencv library).
So any idea/help will be welcome! (and sorry for my poor english)
I was missing the path to dll in my bat file,
new call is:
java "-Djava.library.path="C:\opencv\build\java\x64 -jar RecupPhoto.jar
compiled my project in netbeans IDE and when I run the jar nothing happens just gives me a error occured while trying to run it. I think I found the problem just not sure how to fix it. Help please!
This is what happens when I check the jar in CMD
C:\Users\Mac\Desktop>java -jar dist\pong.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.libr
ary.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:95)
at org.lwjgl.Sys.<clinit>(Sys.java:112)
at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
at mw.Main.initDisplay(Main.java:36)
at mw.Main.main(Main.java:25)
C:\Users\Mac\Desktop>
When I check the manifest file it's pretty much empty:
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
when I check the jar in CMD C:\Users\Mac\Desktop>java -jar dist\pong.jar
You need to use the -cp switch while running the jar using the java command.
Documentation
You can easily google to find more examples on how does -cp works.
You need to create a library and add a reference to it in your project
See Setting Up LWJGL with Netbeans
At a guess I'd say you are missing step 5 from Setting Up a Project to Use LWJGL in NetBeans
Finally, you need to tell NetBeans where the Native Libraries (i.e, DLL, JNILIB, DYLIB, SO files) are for your system so that the natives are linked when running.
Select the Run category and then type the following into the VM Options, replacing what is in bold to suit your system:
-Djava.library.path=<lwjgl-X.X path>/native/<linux|macosx|solaris|windows>
Update: Didn't realise you were doing it from the command prompt. You say you are running
java -jar dist\pong.jar
You need to add the -D option so something like this:
java -Djava.library.path=<lwjgl-X.X path>/native/windows -jar dist\pong.jar
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
all am working a project for compiling and running a java source code via my application.
here am stuck will explain my environment here..
java 1.6.0_35 32bit and eclipse indigo using operating system windows 64 bit
when i used this code
String command = "javac "+file.getAbsolutePath();
System.out.println(command);
Process p = Runtime.getRuntime().exec(command);`
got this exception ..think error show file doesnt exist but i checked it,which is here
and when i execute via command line which compiles,but the eclipse shows this error
java.io.IOException: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)`
can anyone fix this ,i tried a lot ..
You don't need to use the command line, you can access javac programmatically:
JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
javac.run(null, null, null, arguments);
See
The Java 6.0 Compiler API
and http://openjdk.java.net/groups/compiler/guide/compilerAPI.html for examples
It is portable (works on other systems) and will avoid problems with paths and command line.
You can use Java 6 Compiler API . Also this link might be useful..
Your problem seems not so much that the file you want to compile is not found, but that the javac command itself is not found. Make sure that the Runtime can find the javac executable, eventually by passing the "PATH=/path/to/java/dir" to exec.
See: Runtime.exec(command, enviroment, dir)