Ask Your Question

Distribute Opencv java project?

asked 2016-01-06 11:35:33 -0500

updated 2016-01-13 14:25:01 -0500

Forgive the newbie question - Eclipse 3.8 Ubuntu 14.04 - java project runs under Eclipse a-ok. I would like to export to production and distribute .jar to other linux users. However, what I am reading so far indicates the users must install Opencv on their own systems before they can use my program. Is that correct? If not - what steps can I take to make this as painless as possible on the users who are unlikely to be very computer literate.

* please see my update below and post assistance if you can

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2016-01-07 01:39:35 -0500

RolandC gravatar image

You need to distribute only the jar file and the libraries for the given operating system. There's no need for the users to have OpenCV "installed".

A possibility would be that you distribute a compressed / extractable package (tar, zip, jar, etc) with all the classes and libraries, including a shell command to start the application.

You can read about how to start the application here.

edit flag offensive delete link more


I was able to run the .jar file successfully on the machine where opencv is installed using the -Djava.library.path="/my/path" command linking the to the .jar.

However, when I run on a different machine where opencv is not installed I have encounted: "java.lang.unstatisfiedlinkerror: cannot open shared object file.: No such file or directory" I have brought over the file over and built a link file that it references the libopencv_ but no success. Same error.

Softwar gravatar imageSoftwar ( 2016-01-10 18:30:10 -0500 )edit

answered 2016-01-13 09:15:54 -0500

updated 2016-01-16 18:37:47 -0500

The answer is the Opencv libraries need to be stored on the installation machine in exactly the same directories as the production machine. In my case, I may have not used the right directories during my initial installation on the production machine - storing the opencv libraries in my workspace.

First, I created the same directories on the installation PC /home/me/OpenCV/opencv-3.1.0/build/lib and copied all the opencv libraries from the production machine into that directory.

Second, I used ldd /home/me/ to find the libraries with missing links.

Third, I used ln -s library.file name to create each link as named in the ldd output.

Fourth, I had to copy over and create links for some libraries stored in the system area /usr/lib and /usr/lib/x86_64-linux-gnu that were also highlighted as missing in the ldd output from

Finally, I was able to execute the program java -Djava.library.path="/home/me/OpenCv/opencv-3.1.0/build/lib" -jar program.jar

My next step will be to automate this process with either a shell or some other utility and zip files to contain all the data. I suspect that I should carry ALL the library files from the ldd output and create the links just in case the installation machine does not have any of them.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-01-06 11:35:33 -0500

Seen: 1,111 times

Last updated: Jan 16 '16