How to compile and install OpenCV in Eclipse


In this post I will show you how to compile and install OpenCV.

OpenCV logo

1. Download and compile


  • Latest Java Version
  • CMake
  • Apache Ant


Github logo

First type in

git clone
(to get OpenCV's source code) then
cd opencv
(go into the clonned directory).


Then create a build directory:

mkdir build
and go into it.
cd build

Here type in your Java's home directory,

export JAVA_HOME=*here the directory*
then type in:

If everything goes well, you see that Java Tests, Java Wrappers, and Ant are passed, issue this command:

make -j8
(the latter in theory runs faster, but crashed my system :( )

If everything went well you should have opencv-3xx.jar in the /opencv/build/bin directory and in the /opencv/build/lib directory.

2. Install it in Eclipse

Eclipse's logo

Open Eclipse and select a workspace of your choice. Create a User Library, ready to be used on all your next projects: go to

Window > Preferences...

From the menu navigate under

Java > Build Path > User Libraries
and choose
Enter a name for the library (e.g., opencv) and select the newly created user library. Choose
Add External JARs...
, browse to select opencv-3xx.jar from your computer. After adding the jar, extend it, select
Native library location
and press


External Folder...
and browse to select the folder containing the OpenCV libraries. (opencv_directory/build/lib on Linux)

Solution Worked 0 UpvotesUpvote


Solution Didn't Worked 0 DownvotesDownvote



Search Tags