Need help with javacpp-presets?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

1.9K Stars 582 Forks Other 1.4K Commits 140 Opened issues


The missing Java distribution of native C++ libraries

Services available


Need anything else?

Contributors list

JavaCPP Presets

Gitter Maven Central Sonatype Nexus (Snapshots)
Build status for all platforms (Android, iOS, Linux, Mac OS X, Windows): opencv ffmpeg flycapture spinnaker libdc1394 libfreenect libfreenect2 librealsense librealsense2 videoinput artoolkitplus chilitags flandmark arrow hdf5 hyperscan mkl mkl-dnn dnnl openblas arpack-ng cminpack fftw gsl cpython numpy scipy gym llvm libffi libpostal leptonica tesseract caffe openpose cuda nvcodec opencl mxnet pytorch tensorflow tensorflow-lite tensorrt ale depthai onnx ngraph onnxruntime tvm liquidfun qt skia cpu_features modsecurity systems
Commercial support and paid services for custom presets: xscode


The JavaCPP Presets modules contain Java configuration and interface classes for widely used C/C++ libraries. The configuration files in the

packages are used by the
to create from C/C++ header files the Java interface files targeting the
packages, which is turn are used by the
and the native C++ compiler to produce the required JNI libraries. Moreover, helper classes make their functionality easier to use on the Java platform, including Android.

For orientation purposes, the documentation of this repository can be thought of as being split into 2 levels:

  1. The directory where this parent document is located belongs to the upper level, the
    module itself, and
  2. The subdirectories in it are the actual child modules, with their files, presets, and packages, as the lower level.

This parent file contains general information applicable to all modules to solve issues concerning downloads, common requirements, installation procedures, and build instructions. The respective files in each subdirectory contain extra information, links, and notes concerning API documentation, specific requirements, dependencies for

files, and sample usage code, for the presets and packages of each module. Please be aware that not all of the presets have the same level of maturity, and the style and layout may also differ from one to another since they are based on the APIs of third-party libraries.

Please refer to the wiki page for more information about how to create new presets. Since additional documentation is currently lacking, please also feel free to ask questions on the mailing list or the discussion forum.


JAR files containing binaries for all child modules and builds for all supported platforms (Android, iOS, Linux, Mac OS X, and Windows) can be obtained from the Maven Central Repository. Archives containing these JAR files are also available as releases.

To install manually the JAR files, follow the instructions in the Manual Installation section below.

We can also have everything downloaded and installed automatically with:

  • Maven (inside the

  • Gradle (inside the

    dependencies {
    implementation group: 'org.bytedeco', name: moduleName + '-platform', version: moduleVersion + '-1.5.6'
  • Leiningen (inside the

    :dependencies [
    [~(symbol (str "org.bytedeco/" moduleName "-platform")) ~(str moduleVersion "-1.5.6")]
  • sbt (inside the

    libraryDependencies += "org.bytedeco" % moduleName + "-platform" % moduleVersion + "-1.5.6"

where the

variables correspond to the desired module. This downloads binaries for all platforms, but to get binaries for only one platform we can set the
system property (via the
command line option) to something like
, etc. We can also specify more than one platform, see the examples at Reducing the Number of Dependencies. Another option available to Gradle users is Gradle JavaCPP, and similarly for Scala users there is SBT-JavaCPP.

Required Software

To use the JavaCPP Presets, you will need to download and install the following software:

  • An implementation of Java SE 7 or newer:
    • OpenJDK or
    • Oracle JDK or
    • IBM JDK

Further, in the case of Android, the JavaCPP Presets also rely on:

  • Android SDK API 21 or newer

Manual Installation

Simply put all the desired JAR files (

, etc.), in addition to
, somewhere in your class path. The JAR files available as pre-built artifacts are meant to be used with JavaCPP. The binaries for Linux were built for CentOS 6 and 7, so they should work on most distributions currently in use. The ones for Android were compiled for ARMv7 processors featuring an FPU, so they will not work on ancient devices such as the HTC Magic or some others with an ARMv6 CPU. Here are some more specific instructions for common cases:

NetBeans (Java SE 7 or newer):

  1. In the Projects window, right-click the Libraries node of your project, and select "Add JAR/Folder...".
  2. Locate the JAR files, select them, and click OK.

Eclipse (Java SE 7 or newer):

  1. Navigate to Project > Properties > Java Build Path > Libraries and click "Add External JARs...".
  2. Locate the JAR files, select them, and click OK.

IntelliJ IDEA (Android 5.0 or newer):

  1. Follow the instructions on this page:
  2. Copy all the JAR files into the
  3. Navigate to File > Project Structure > app > Dependencies, click
    , and select "2 File dependency".
  4. Select all the JAR files from the

After that, we can access almost transparently the corresponding C/C++ APIs through the interface classes found in the

packages. Indeed, the
translates the code comments from the C/C++ header files into the Java interface files, (almost) ready to be consumed by Javadoc. However, since their translation still leaves to be desired, one may wish to refer to the original documentation pages. For instance, the ones for OpenCV and FFmpeg can be found online at:

Build Instructions

If the binary files available above are not enough for your needs, you might need to rebuild them from the source code. To this end, project files on the Java side were created as Maven modules. By default, the Maven build also installs the native libraries on the native C/C++ side with the
scripts, but they can also be installed by other means.

Additionally, one can find on the wiki page additional information about the recommended build environments for the major platforms.

The Maven modules

The JavaCPP Presets depend on Maven, a powerful build system for Java, so before attempting a build, be sure to install and read up on:

  • Maven 3.x
  • JavaCPP 1.5.6

Each child module in turn relies by default on the included
scripts, explained below, to install its corresponding native libraries in the

subdirectory. To use native libraries already installed somewhere else on the system, other installation directories than
can also be specified either in the
files or in the
configuration files. The following versions are supported:
  • OpenCV 4.5.3
  • FFmpeg 4.4.x
  • FlyCapture 2.13.x
  • Spinnaker 2.4.x
  • libdc1394 2.2.6
  • libfreenect 0.5.7
  • libfreenect2 0.2.0
  • librealsense 1.12.x
  • librealsense2 2.44.x
  • videoInput 0.200
  • ARToolKitPlus 2.3.1
  • Chilitags
  • flandmark 1.07
  • Arrow 4.0.x
  • HDF5 1.12.x
  • Hyperscan 5.4.x
  • MKL 2021.x
  • MKL-DNN 0.21.x
  • DNNL 2.3.x
  • OpenBLAS 0.3.17
  • ARPACK-NG 3.8.0
  • CMINPACK 1.3.8
  • FFTW 3.3.9
  • GSL 2.7
  • CPython 3.9.x
  • NumPy 1.21.x
  • SciPy 1.7.x
  • Gym 0.18.x
  • LLVM 12.0.x
  • libffi 3.4.x
  • libpostal 1.1-alpha
  • Leptonica 1.81.x
  • Tesseract 4.1.1
  • Caffe 1.0
  • OpenPose 1.7.0
  • CUDA 11.4.x
    • cuDNN 8.2.x
    • NCCL 2.10.x
  • NVIDIA Video Codec SDK 11.1.x
  • OpenCL 3.0
  • MXNet 1.8.0
  • PyTorch 1.9.x
  • TensorFlow 1.15.x
  • TensorFlow Lite 2.5.x
  • TensorRT 8.x
  • The Arcade Learning Environment 0.6.x
  • DepthAI 2.8.x
  • ONNX 1.9.x
  • nGraph 0.26.0
  • ONNX Runtime 1.8.x
  • TVM 0.7.0
  • LiquidFun
  • Qt 5.15.x
  • Mono/Skia 2.80.x
  • cpufeatures 0.6.0
  • ModSecurity 3.0.5
  • System APIs of the build environments:
    • Linux (glibc)
    • Mac OS X (XNU libc)
    • Windows (Win32)

Once everything installed and configured, simply execute

$ mvn install --projects .,opencv,ffmpeg,etc. -Djavacpp.platform.root=/path/to/android-ndk/
inside the directory containing the parent
file, by specifying only the desired child modules in the command, but without the leading period "." in the comma-separated list of projects, the parent
file itself might not get installed.
option is required only for Android builds.) Also specify
as option to skip the execution of the
scripts. In addition to
, some of the presets can also be built against CUDA with
or CPython with
. Please refer to the comments inside the
file for further details. From the "platform" subdirectory, we can also install the "platform" artifacts with a similar command:
$ cd platform
$ mvn install --projects ../opencv/platform,../ffmpeg/platform,etc.


Running the scripts allows us to install easily the native libraries on multiple platforms, but additional software is required:

  • A recent version of Linux, Mac OS X, or Windows with MSYS and Visual Studio
  • Android NDK r18 or newer (required only for Android builds)

With the above in working order, the scripts get launched automatically as part of the Maven build lifecycle, but we can also manually execute

$ ANDROID_NDK=/path/to/android-ndk/ bash [-platform ] [-extension ]  [projects]
where possible platform names are:
, etc. The
extension as supported by some builds also require CUDA to be installed. (The
variable is required only for Android builds.) Please note that the scripts download source archives from appropriate sites as necessary.

To compile binaries for an Android device with no FPU, first make sure this is what you want. Without FPU, the performance of either OpenCV or FFmpeg is bound to be unacceptable. If you still wish to continue down that road, then replace "armeabi-v7a" by "armeabi" and "-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16" with "-march=armv5te -mtune=xscale -msoft-float", inside various files.

Although JavaCPP can pick up native libraries installed on the system, the scripts exist to facilitate the build process across multiple platforms. They also allow JavaCPP to copy the native libraries and load them at runtime from the JAR files created above by Maven, a useful feature for standalone applications or Java applets. Moreover, tricks such as the following work with JNLP:


Thanks to Jose Gómez for testing this out!

How Can I Help?

Contributions of any kind are highly welcome! At the moment, the

has limited capabilities, so I plan to improve it gradually to the point where it can successfully parse large C++ header files that are even more convoluted than the ones from OpenCV, Caffe, or TensorFlow, but the build system could also be improved. Consequently, I am looking for help especially with the five following tasks, in no particular order:
  • Setting up continuous integration, preferably free on the cloud (Travis CI?)
  • Improving the
    (by using the presets for LLVM and Clang?)
  • Providing builds for more platforms, as with
    for Raspberry Pi, etc.
  • Replacing the Bash/Maven build combo by something easier to use (Gradle?)
  • Adding new presets as child modules for other C/C++ libraries (Caffe2, OpenNI, OpenMesh, PCL, etc.)

To contribute, please fork and create pull requests, or post your suggestions as a new "issue". Thank you very much in advance for your contribution!

Project lead: Samuel Audet samuel.audet

Developer site:
Discussion group:

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.