1

Good day everyone, please I'm new to opencv and I'm using it in java swing to develop a camera app. Everything works fine in netbeans but when I export the jar file and doublclick it, nothing happens. I've set my VM options using -DJavalibrary.path. I've also loaded opencv in my main methods using System.load(path+Core.NATIVE_LIBRARY_NAME+ ".dll").

I browsed about the problem and some suggested I copy the opencv.dll file into jre bin folder, I did that and nothing happened also.

The funny thing is that when I run my app through cmd using java -jar "path" everything works fine but double clicking the jar file does nothing. Please help

Emperor
  • 81
  • 1
  • 9

1 Answers1

1

Your settings will not be persisted, so you have to specify them at every run.

When you double clicks on the generated jar, it will run by the associated default program with the default options, so neither the classpath, nor the library path, nor any JVM option will not be given (except those that are defined in either system or user environment variables - but those are general settings and I would not recommend to specify the necessary attributes in this way).

I would suggest to create a bat/cmd file with your command and every options (classpath, library path and JVM) you have specified by running it as java -jar, then run your app by double clicking on your bat/cmd file.

You have to set at leas the PATH variable for your script in order to find your java.exe. You can specify it with full path too:

"C:\Program Files\Java\jdk1.8.0_131\bin\java.exe" -jar ...

You can do it globally via environment variable, as Oracle suggest or locally, by setting the JAVA_HOME and PATH variable.

You can modify your bat file to hide the console after you have tested that it works correctly.

m4gic
  • 1,461
  • 12
  • 19
  • Thanks m4gic fot your reply. I've created a batch file which has the correct classpath but when I doubleclick the bat, it says windows cannot find the path. This is what is in the .bat file: java -jar "C:\Users\EMPEROR-CUZZY\Documents\NetBeansProjects\LOGARTS\dist\LOGARTS.jar" – Emperor Sep 06 '18 at 06:41
  • Perfect. I set my system variable path and java_home using your link. The .bat file now opens up my software and everything works fine. Thanks m4gic, you've really helped me. Another thing is that it also opens up cmd along with the software and I have to manually close cmd. Is there anyway to prevent cmd from opening at all? – Emperor Sep 07 '18 at 11:55
  • Yea its okay now. Thanks very much – Emperor Sep 08 '18 at 19:47