0

I got a programm which use the opencv library that run well on netbeans but when i try to run it outside of netbeans using this command:

java -jar RecupPhotoV1
pause

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 recupphoto.Ihm.<init>(Ihm.java:96)
        at recupphoto.RecupPhoto.main(RecupPhoto.java:18)

I got the project builded into the folder dist, with jar here and opencv_300.jar in a lib folder. My objective is to make this app runnable on other computers whithout netbeans just by lauching a .bat or a script in the same folder than my jar

-----------------------------------------------------------------------------

edit: Tried some things yesterday, i exported my project from netbeans to eclipse, followed a new tutorial with new manifest etc and i think, things are going better. Now if i execute:

java -jar RecupPhoto.jar

with this manifest:

Manifest-Version: 1.0
Main-class: RecupPhoto
Class-path: opencv-300.jar

i got a thread error,

Exception in thread "main" java.lang.NoClassDefFoundError: org/opencv/videoio/VideoCapture
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.getDeclaredMethod(Unknown Source)
        at java.awt.Component.isCoalesceEventsOverriden(Unknown Source)
        at java.awt.Component.access$500(Unknown Source)
        at java.awt.Component$3.run(Unknown Source)
        at java.awt.Component$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.Component.checkCoalescing(Unknown Source)
        at java.awt.Component.<init>(Unknown Source)
        at java.awt.Container.<init>(Unknown Source)
        at java.awt.Window.<init>(Unknown Source)
        at java.awt.Frame.<init>(Unknown Source)
        at java.awt.Frame.<init>(Unknown Source)
        at javax.swing.JFrame.<init>(Unknown Source)
        at Ihm.<init>(Ihm.java:82)
        at RecupPhoto.main(RecupPhoto.java:10)
Caused by: java.lang.ClassNotFoundException: org.opencv.videoio.VideoCapture
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 17 more

Duno what can be the cause of it?

Neithalf
  • 243
  • 4
  • 11

1 Answers1

0

The opencv jar must be in the classpath. You must run something like:

java -classpath /path/to/lib -jar RecupPhotoV1

  • java -classpath '../lib/opencv-300' -jar RecupPhotoV1 pause told me: Error: Unable to access jarfile RecupPhotoV1 – Neithalf Jun 08 '15 at 13:22
  • Can you try with '../lib/opencv-300.jar' – Pouriya Zarbafian Jun 08 '15 at 13:24
  • I got same problem unable to acces jarfile – Neithalf Jun 08 '15 at 13:27
  • Does the jar exist, is the path correct. You should find detailed response here : http://stackoverflow.com/questions/2910115/include-external-jar-when-running-java-jar – Pouriya Zarbafian Jun 08 '15 at 13:37
  • Okay seems to go on, now using this " java -cp /lib/opencv-300.jar RecupPhotoV1 pause " i got "unable to find main class RecupPhotoV1 – Neithalf Jun 08 '15 at 13:53
  • The manifest is there but there so i thinks it's okay? "Manifest-Version: 1.0 Ant-Version: Apache Ant 1.9.4 Created-By: 1.8.0_45-b15 (Oracle Corporation) Class-Path: lib/opencv-300.jar X-COMMENT: Main-Class will be added automatically by build Main-Class: recupphoto.RecupPhoto" – Neithalf Jun 08 '15 at 14:08
  • The "X-COMMENT: Main-Class will be added automatically by build" is still annoying me, dunno what it mean – Neithalf Jun 08 '15 at 14:09
  • You also need the opencv DLL. – Pouriya Zarbafian Jun 08 '15 at 14:26
  • In which folder should i put it? And is there anything special to add in manifest or other places? – Neithalf Jun 08 '15 at 14:28
  • Look here: http://stackoverflow.com/questions/4996724/opencv-dll-and-java-library-path – Pouriya Zarbafian Jun 08 '15 at 14:30
  • Either on your PATH, or in the path specified by -Djava.library.path if you use that option. – Pouriya Zarbafian Jun 08 '15 at 14:33
  • In netbeans project properties i specified "-Djava.library.path="C:\opencv\build\java\x64"" Which seems to be working while i run the programm on netbeans – Neithalf Jun 08 '15 at 14:45
  • I still get the error about java can't find the main class, which is disapointing me, cause it's well defined in manifest – Neithalf Jun 08 '15 at 14:58
  • Last idea do you also add "-Djava.library.path="C:\opencv\build\java\x64" when running the jar. – Pouriya Zarbafian Jun 09 '15 at 07:12
  • It's added into netbeans' running properties into my project, so i guess it's added – Neithalf Jun 09 '15 at 14:18
  • Thanks for all the help you given me so far, i added the command but still got missing main class, which is not in the D java path but in RecupPhotoV1 – Neithalf Jun 10 '15 at 06:16
  • Sorry but I'm out of ideas. Go step by step and make sure verything is fine. Your command should look like 'java "-Djava.library.path="C:\opencv\build\java\x64 -classpath /path/to/lib -jar RecupPhotoV1.jar" – Pouriya Zarbafian Jun 11 '15 at 08:26
  • Good choice. You are missing a jar, if your opencv jar is not packaged with your jar you need to specify a classpath like previously. – Pouriya Zarbafian Jun 11 '15 at 12:04
  • Can the classpath be relative (like "lib/opencv-300.jar")? Still got the error if i had -cp in the bat file – Neithalf Jun 11 '15 at 12:10