First time here? Check out the FAQ!

Ask Your Question
0

Running a Java Program Referencing OpenCV's Jar File

asked Oct 15 '15

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.

Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Nov 19 '15

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.

Preview: (hide)

Comments

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

BlacKKnighT74 gravatar imageBlacKKnighT74 (Dec 13 '19)edit

Question Tools

1 follower

Stats

Asked: Oct 15 '15

Seen: 1,697 times

Last updated: Nov 19 '15