Java interoperability

Ballerina offers a straightforward way to call the existing Java code from Ballerina. Although Ballerina is not designed to be a JVM language, the current implementation, which targets the JVM, aka jBallerina, provides Java interoperability by adhering to the Ballerina language semantics.

Ballerina bindings to Java code

You can write Ballerina code (Ballerina bindings) that lets you call the corresponding Java API as illustrated in the diagram below.

Ballerina bindings to Java code

The next section of this reference guide explains the Bindgen Tool that can be used to generate these bindings automatically while eliminating the need for understanding the Ballerina FFI layer.

The Ballerina FFI section explains how to write these bindings manually. It is useful for those who would like to understand the inner workings of calling Java from Ballerina and for those who want to customize the bindings generated by the bindgen tool.