Installing OpenCV with Java in our lab, and configuring Eclipse


1. Make a directory to host your OpenCV work:

> mkdir Vision

2. Go into that directory:

> cd Vision

3. Get all the OpenCV files from the git repository:

> git clone git://
> cd opencv

4. Make a directory for building OpenCV

> mkdir build

5. Go into that directory

> cd build

6. Generate a makefile specific to your environment, using cmake:


7. Now build OpenCV:

> make -j8

(The very last things this builds are the jar files that we need for using OpenCV with Java. So, if the build process ever generates an “Error”, just re-enter the previous command, and let it re-start where it left off.)

8. Now we set up Eclipse to use what we’ve built. Whithin Eclipse, go to Window -> Preferences. On the left side select Java -> Build Path -> User Libraries. Then click the “New” button.

9. Name this new library “OpenCV-3.0.0” . (The version of OpenCV that I built when following the directions above was 3.0.0. If for some reason you built a different version, name the library accordingly.) Click “OK”.

10. Select your new library in the list, and click the “Add External JARs” button. Find the “Vision” folder you created at the start of this tutorial, and navigate to Vision/opencv/build/bin, and select the “opencv-300.jar” file, and click “OK”.

11. Click the triangle next to that jar to expand it, select the “Native library location” entry, and click “Edit.” Click the “External Folder” button, browse to “Vision/opencv/build,” highlight “lib”, and click “OK”.

12. Click “OK” again to finish up, and you should now be able to create and build OpenCV projects.

* When creating a new project, be sure to add the OpenCV-3.0.0 library to the list of Libraries
* If you already have a project, then go to Project -> Properites, select Resource -> Java Build Path, go to the Libraries tab, and add OpenCV-3.0.0 as a user library to your project.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s