Ask Your Question
0

Running a Java Program Referencing OpenCV's Jar File

asked 2015-10-15 00:09:38 -0600

zachkerr0987 gravatar image

I'm finding it impossible to run my program that's relying on the OpenCV jar file. I have compiled with "javac -cp opencv-300.jar *.java", but trying to run java Program meant it couldn't find the main class, so I ran with java Program.Program which threw exceptions regarding finding the OpenCV classes.

I tried java "-Djava.library.path=". -jar opencv-300.jar but that only returned "no main manifest attribute, in opencv-300.jar". I tried uncompiling the jar and running with java -cp . Program.Program and it returned "UnsatisfiedLinkError: no opencv_java300 in java.library.path", but that seems like a terrible path.

Does anybody have any clue how I can make the damn thing run? Trying on Windows 8 and Ubuntu 14.04LTS, with identical results on both. Please help!

Edit: I can upload a public Dropbox link so people can see for themselves if that would help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-11-19 00:56:43 -0600

RolandC gravatar image

Assuming you have this folder structure:

opencv/application/Main.class
opencv/lib/opencv-300.jar
opencv/lib/x64/opencv_java300.dll

with the Main class having the package declaration "application" and your command prompt being in the folder opencv you can start the app this way:

java -cp .;lib/opencv-300.jar -Djava.library.path=lib/x64 application.Main

The "." is needed for the main class, the jar is needed for the main class, the library is needed for the jar.

edit flag offensive delete link more

Comments

I'm trying to compile in terminal. What about that .dll file for ubuntu?

BlacKKnighT74 gravatar imageBlacKKnighT74 ( 2019-12-12 23:25:05 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-10-15 00:09:38 -0600

Seen: 1,568 times

Last updated: Nov 19 '15