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 Ballerina FFI explains how to write the Ballerina bindings manually. Learning to write them manually helps you to understand the inner workings of calling Java from Ballerina.

Alternatively, you can use the Bindgen Tool to generate these bindings automatically while eliminating the need for understanding the Ballerina FFI layer. It also explains how to customize the bindings generated by the Bindgen Tool.