How to Use OpenCV with Java under NetBeans IDE

January 25, 2018 Author: rajesh
Print Friendly, PDF & Email

This post will assist to developers who want to work  with Java and OpenCV environment. Here, we demonstrate how to use OpenCV with netbeans IDE.  In this post, we explain how to configure the netbeans IDE to facilitate execution of OpenCV applications. OpenCV 2.4.8 used for Java application, OpenCV supports Java from OpenCV 2.4.4 version.


OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products. Being a BSD-licensed product, OpenCV makes it easy for businesses to utilize and modify the code.

Currently OpenCV supports a wide variety of programming languages like C++, Python, Java etc and is available on different platforms including Windows, Linux, OS X, Android, iOS etc. Also, interfaces based on CUDA and OpenCL are also under active development for high-speed GPU operations.

OpenCV-Python is the Python API of OpenCV. It combines the best qualities of OpenCV C++ API and Python language.

OpenCV Basics: How to Start Work?

Start with Netbeans IDE: Configuration Process

The subsequent steps show how to configure the netbeans 6.9.1 description with OpenCV 2.4.8 version. First of all, create the project. Then select the library shown in projects window. Then follow the following steps.

Step 1: Add Library Choose Libraries from netbeans project, right Click on Libraries, and click “Add Library”. Select Libraries> right click Libraries>Click Add Library.
Step 2: Create Library Click on “Create” button to create new library. Enter the Library Name, as “OpenCV2.4.8”. Click on “OK” Button.
Step 3: Customize Library Choose Classpath tab to add class path. Click on “Add JAR/Folder” to add class path. Select file path “c:\opencv\build\java\opencv-248.jar“. Click on “OK” button.
Step 4: Add Library Choose Configured library as,”opencv2.4.8″. Click on “Add Library” button to add library to project work space.
Step 5: Project Properties Choose project, right click on “Properties”. Select “Run” option, Change VM options to add native library “-Djava.library.path=”C:\opencv\build\java\x86″”. If you have a 32-bit system, you need to select the x86 folder instead of x64.

Screenshot: Demonstration of Integration of OpenCV with Netbeans IDE

Add Library to netbeans

Figure 1: Add Library

Create Library

Figure 2: Create Library

Customize Library

Figure 3: Customize Library

Add Library

Figure 4: Add Library

Project Properties

Figure 5: Change in Project Properties


[1] “About: OpenCV”, available online at:

[2] “How to Use OpenCV with Java under NetBeans IDE”, available online at:

[3] Rorasa, “OpenCV with Netbeans IDE” available online at:, 19/08/2009


No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Insert math as
Additional settings
Formula color
Text color
Type math using LaTeX
Nothing to preview