Java bindings for OpenCL
This site contains Java bindings for OpenCL, the Open C
OpenCL allows writing programs for heterogeneous platforms that utilize CPUs or GPUs. More
information about OpenCL may be found at the
Khronos OpenCL website.
The following implementations of OpenCL are currently available:
General information about Java bindings for OpenCL
There are several libraries providing Java bindings for OpenCL. Here is
an overview of some of these libraries:
The JOCL that is available here
This library offers Java-Bindings for OpenCL that are very similar to
the original OpenCL API. The functions are provided as static methods,
and semantics and signatures of these methods have been kept consistent
with the original library functions, except for the language-specific
limitations of Java. The OpenCL API may be very verbose at some points,
and this is not hidden or simplified, but simply offered by JOCL as-it-is.
The goal of this library is to provide an object-oriented abstraction
of OpenCL for Java. This simplifies the usage and may be found more natural and
convenient for most Java Programmers. The library also offers a low-level
interface, which is generated using the GlueGen library. This interface
is similar to the OpenCL API, but not really intended to be used by clients,
and mainly serves as the basis for the object-oriented wrapper.
This library also offers an object-oriented abstraction of OpenCL for Java.
It has a low-level interface which is based on JNA and generated using
the JNAerator library. The low-level interface serves as the basis for
the object-oriented wrapper but is not intended to be used by clients.
Note that JavaCL is part of the
NativeLibs4Java project, which also contains
a library for accessing OpenCL with Scala.
OpenCL support in LWJGL
The Lightweight Java Game Library (LWJGL) has been extended
to also support OpenCL in version 2.6. The original OpenCL API
is mapped to a similar Java API, and extended with convenience
As an alternative for Java developers who want to benefit from the computing
power of their GPU without having to learn OpenCL, AMD has published
It allows a seamless integration of GPU workloads into Java Code. The Java bytecode
will be converted into OpenCL code and executed on the GPU, transparently for the user.
Even if there is no OpenCL implementation, the same code will still run on the
CPU in a Java Thread Pool, taking advantage of multiple CPU cores.
: Scala samples uploaded
Piotr Tarsa has ported some of the JOCL samples to Scala.
They can be found on the Samples page.
: Update to version 0.1.9
The latest version of JOCL, with support for OpenCL 1.2 is now
available in the downloads
section and in the central Maven repository:
: Version 0.1.8 (Release Candidate)
- Update for OpenCL 1.2 support
- This version should be considered as a release candidate.
JOCL has undergone an internal refactoring to allow different
versions for the underlying OpenCL implementation
Additionally, the binaries for Linux 64bit are still missing.
Once they are available, the final version will be uploaded
and made available in the Maven repository.
: OpenCL cloth simulation demo updated
- The JOCL Cloth simulation demo has been
updated. A bug in the simple renderer library has been fixed, which
caused a rendering failure with newer NVIDIA drivers. Additionally,
a new method for subdividing the edge set for the Java based
simulation method has been implemented.
: OpenCL cloth simulation demo updated
- The JOCL Cloth simulation demo has been
updated. It now allows selecting the OpenCL platform and device for
the execution. Additionally, it uses some utility classes for JOCL
that are currently developed. Once the API of these classes is more
stable, they will be available as a separate library.
: OpenCL cloth simulation demo uploaded
: Version 0.1.7
- CLException now provides the CL status code that caused the exception
- Vendor-independent constants from the CL extensions have been added
The native libraries now contain a version number in their name, and
the behavior of the native library loading utility class has changed.
See the change log for details.
: Samples updated
Most of the samples have been updated to use an initialization
scheme that better supports multiple OpenCL platforms.
Additionally, the OpenGL-related samples have been updated
to properly work with the newest OpenGL versions, which require
a vertex array object to be created whenever a vertex buffer
object is used.
: Version 0.1.6
The latest version of JOCL contains only a bugfix for MacOS:
The MacOS library could not be loaded from the JAR
file due to a wrong assumption about the library
: Version 0.1.5 available in the Maven repository
The latest version of JOCL, including binaries for 32/64bit
Windows, 32/64 bit Linux and 64bit MacOS, is now available
in the central Maven repository:
Thanks to Kashif Rasul for providing the 64 bit Linux and MacOS binaries.
: Update to version 0.1.5 - fixed memory leak
The downloads section
contains an updated archive with JOCL version 0.1.5, including
an important fix of a memory leak for clEnqueue* operations.
The archive currently contains the Windows 32 and 64 bit binaries.
Other binaries will follow soon.
: Linux 32bit library added
The binary distribution archive which is available in the
now also contains Linux 32bit libraries.
: JOCL is now available via the Central Maven Repository
Maven users can now add a dependency to JOCL inside their POM:
The mechanism for loading the native library has been extended
so that it may load the library directly from the JAR. The
current version contains the native libraries for
32 and 64 bit Windows, 64 bit Linux and 64 bit MacOS.
Additional native libraries may be placed in the
java.library.path and will then be loaded from
the local file system.
: Update to JOCL 0.1.4 (beta1) with OpenCL 1.1 support
A beta version of JOCL 0.1.4 has been uploaded. The source code,
documentation and binaries and binaries for Windows 32bit and 64bit
are available in the downloads
section (other binaries will follow soon - if you want to contribute,
feel free to contact me).
Changes for the new version:
(see change log for details)
- Updated to OpenCL 1.1
- Changed license to MIT/X11 license
- Minor bugfixes and improvements
NOTE: Until now, the binaries and new OpenCL 1.1 functions
could only be tested using the CPU implementation from AMD. The
NVIDIA SDK currently does not yet support OpenCL 1.1.
A small program demonstrating some of the new features that have
come with OpenCL 1.1. is available in the
: An experimental library for handling structs has been uploaded
An experimental library has been added on the
which shows how OpenCL structs could be represented
: A utilitiy for tracing JOCL events has been uploaded
This utiltity class may be used to show a bar plot of the commands that are
associated with OpenCL events:
More information is available on the utilities page.
: Update with bugfix for OpenCL / OpenGL interoperability
An update to version 0.1.3a: Due to bug in the native library,
the OpenGL interoperability did not work properly in the previous
version. The updated source code and binaries are available in the
Thanks to Philipp Stelzer for finding the reason for this bug.
Additionally, the samples section
now contains a modified version of the simple GL example, which uses
JOGL 2 to demonstrate the JOCL/JOGL interoperability.
: Binaries for Linux 32 bit and Windows 64 bit uploaded
Pre-built binaries for 32bit Linux and 64 bit Windows are now available in the
: Update to version 0.1.3
The downloads section contains
the new source code and pre-built binaries for 32bit Windows and
64bit MacOS. The MacOS binaries have been provided by Ryan Spicer from
the School of Arts Media and Engieering at Arizona State University.
Other binaries will be uploaded soon.
The new version contains some bug fixes (see
change log for details)
Asynchronous operations are now possible. That means that clEnqueue* methods
are no longer ignoring the 'blocking' flag.