Fork me on GitHub

Bytedeco makes native libraries available to the Java platform by offering ready-to-use bindings generated with the codeveloped JavaCPP technology. This, we hope, is the missing bridge between Java and C/C++.

Core Technologies

  • JavaCPP [API] – A tool that can not only generate JNI code but also build native wrapper library files from an appropriate interface file written entirely in Java. It can also parse automatically C/C++ header files to produce the required Java interface files.

Prebuilt Java Bindings to C/C++ Libraries

These are part of a project that we call the JavaCPP Presets. Many coexist in the same GitHub repository, and all use JavaCPP to wrap predefined C/C++ libraries from open-source land. The bindings expose almost all of the relevant APIs and make them available in a portable and user-friendly fashion to any Java virtual machine (including Android), as if they were like any other normal Java libraries. We have presets for the following C/C++ libraries:

We will add more to this list as they are made, including those from outside the bytedeco/javacpp-presets repository.

Projects Leveraging the Presets Bindings

  • JavaCV [API] – Library based on the JavaCPP Presets that depends on commonly used native libraries in the field of computer vision to facilitate the development of those applications on the Java platform. It provides easy-to-use interfaces to grab frames from cameras and audio/video streams, process them, and record them back on disk or send them over the network.
  • JavaCV Examples – Collection of examples originally written in C++ for the book entitled OpenCV 2 Computer Vision Application Programming Cookbook by Robert Laganière, but ported to JavaCV and written in Scala.
  • ProCamCalib – Sample JavaCV application that can perform geometric and photometric calibration of a set of video projectors and color cameras.
  • ProCamTracker – Another sample JavaCV application that uses the calibration from ProCamCalib to implement a vision method that tracks a textured planar surface and realizes markerless interactive augmented reality with projection mapping.

More Project Information

Please refer to the contribute and download pages for more information about how to help out or obtain this software.

See the developer site on GitHub for more general information about the Bytedeco projects.

Latest News feed

Java as a system programming language

January 17, 2018

Happy New Year! After spending over a year in (part-time) preparation for the next major release here at Bytedeco, version 1.4 has finally been released! A lot has been happening, so let me summarize the most important items. First, a million thanks to Vincent Baines for all the hard work getting builds to pass. We now have a proper continuous integration (CI) infrastructure based on AppVeyor and Travis CI testing builds for pull requests as well as publishing SNAPSHOT artifacts for all platforms at each commit to the source code repositories. More information about that on the builds page. Next, we have introduced the concept of “extension” to JavaCPP, letting us provide separate but optional CUDA builds for OpenCV, Caffe, and TensorFlow. To enable them, one simply needs to add to the class path the JAR files containing “-gpu” in their names, and JavaCPP will automatically pick them up based on their contents. On load error, it also gracefully fall backs on non-CUDA binaries. The list of currently available CUDA artifacts is given at the bottom of the download page. Finally, we have been busy closing the gap that prevents Java from being usable as a system programming language by introducing the JavaCPP Presets for Systems to access system APIs such as libc and Win32.

Before going into more details on the latter topic at hand, please find a complete list of all changes in the files for JavaCPP, JavaCPP Presets, JavaCV, ProCamCalib, and ProCamTracker. Binaries can be obtained as usual from the Maven Central Repository. New presets that were contributed include libfreenect2, MKL, libpostal, The Arcade Learning Environment (ALE), LiquidFun, and Skia, in addition to the system APIs.

Although Java is still the most widely used programming language, according to the TIOBE Index, among many other sources, it is still not considered a system programming language and is conspicuously missing from the list of system programming languages on Wikipedia. However, things are starting to change. Beginning with Java 9, the JDK supports ahead-of-time (AOT) compilation of Java classes, something otherwise supported by Avian and many others for a while already, thus allowing developers to create native executable programs that can be integrated into operating systems. Finally, thanks to JNI, JavaCPP, and now the systems presets, we can benefit easily from all the features (and suffer from all the pitfalls) of C++ right from the Java platform.

Having access to systems APIs allows us to perform any operation supported by the underlying platform that is not otherwise mapped to a high-level Java API. Before the process API updates included in Java 9, it was not possible to query all children and descendants of a process, or to kill forcibly an arbitrary process on the system, but it could still have been done with native APIs. However, it is still not possible, for example, to set the priority of a process on the system without resorting to external tools. With the systems presets, we can accomplish this with just a few lines of code, such as the following to set the current process priority to the lowest level, code that can also be executed interactively in a JShell session:

    import org.bytedeco.javacpp.*;

    String platform = Loader.getPlatform();
    if (platform.startsWith("linux")) {
        linux.setpriority(linux.PRIO_PROCESS, linux.getpid(), 20);
    } else if (platform.startsWith("macosx")) {
        macosx.setpriority(macosx.PRIO_PROCESS, macosx.getpid(), 20);
    } else if (platform.startsWith("windows")) {
        windows.SetPriorityClass(windows.GetCurrentProcess(), windows.IDLE_PRIORITY_CLASS);

We can perform the same calls with other tools such as JNA or JNR, but with JavaCPP we get a uniform layer that also supports C++ libraries, providing a level of integration as yet unmatched by any other solutions that we are aware of on any platform. In a nutshell, any language targeting Java bytecode is now in a good position to become a system programming language, on the same level as the Go language!

We hope that you are excited as we are in participating in this grand experiment, so please do not hesitate to contact us via the mailing list from Google Groups, issues on GitHub, or the chat room at Gitter, for any questions that you may have. We hope to hear from all of you soon!