Qt Jenny: Java Code Generator | Qt 6.11
Description: Overview of Qt Jenny

- Qt 6.11
- Qt for Android
- Qt Jenny: Java Code Generator
- Qt 6.11.1 Reference Documentation

# Qt Jenny: Java Code Generator

Qt Jenny translates Java APIs to Qt C++ wrappers, allowing Qt C++ programs to invoke Java functionality. This is particularly useful on a platform with Java system APIs, like Android.

What's new in Qt Jenny |
Qt Jenny installation |
Qt Jenny configuration |
Qt Jenny known issues |
How callbacks work |

## Features

Qt Jenny's features:

- Generation of wrappers for any Java class.
- Templated generation with customizable templates that can be changed to customize the C++ output.
- Configurable generation that allows controlling the namespace of the generated wrappers.
- Support for generating code that uses QJniObject in the generated code, therefore utilizing all the convenience QJniObject brings.

## Examples

See QtJenny Demo for an example how to use Qt Jenny.

## How Qt Jenny works

Qt Jenny translates Java APIs to Qt C++ wrappers by the use of the following building blocks:

- Kotlin code that imports the classes to be wrapped.
- Annotations in that code that tell which classes to wrap.
- A code generator that reads the annotations and generates the wrapper code.

With these building blocks, the Qt project is then structured so that there's a separate Gradle project for generating the code that the Qt CMake project uses. The CMake project triggers the code generation at project configuration time (in other words, when you run CMake). For an application that invokes methods but does not need to implement any callbacks, a single code-generation project is enough. For an application that uses both method invocations and interface callbacks, two generation projects are needed: one for the method proxies and one for the callback hierarchy. For an application that needs to extend classes, three generation projects are needed: one for the method proxies, one for the Java glue code, and one for the callback hierarchy.

The example code in QtJenny Demo uses three generation projects, since it uses class extension.

## Reference

## Licenses and Attributions

Qt Jenny potentially contains third-party modules under the following permissive licenses:

What's new in Qt Jenny |
Qt Jenny installation |
Qt Jenny configuration |
Qt Jenny known issues |
How callbacks work |