Skip to content

How to build QtJambi

Peter Droste edited this page May 10, 2021 · 14 revisions

QtJambi is an open-source project that provides Java language bindings to the Qt APIs. The bindings are generated by inspection of the C++ header files of the Qt implementation then emitting code to provide the necessary JNI (Java Native Interface) and .java files to provide linkage to Java. An application programmer using Qt Jambi would simply add the coresponding Java libraries (.jar files) to their Java project to be able to develop and deploy their application.

Below is described how to build QtJambi binaries from source. If you just want to use QtJambi for your application development you can skip this page and simply use the binaries from the releases. QtJambi is available for Qt5.15, Qt6.0 and Qt6.1. Make yourself familiar with developing applications with QtJambi.

Requirements

  • Apache Ant (min. 1.10.x)
  • Java Development Kit (e.g. OpenJDK, tested with Java 1.8 and 14)
  • Qt 5.15 or 6.x (using the Qt Online Installer)
  • C++ compiler (XCode, Clang, MinGW, MSVC2019)
  • chrpath (Linux only)

Building QtJambi

Edit property qtjambi.skipped.modules in build.properties to exclude Qt modules you don't need to generate.

Windows

  • Open the Visual Studio command prompt for x64 architecture.

to be found in: --> Start Menu --> Programs --> Visual Studio 2019 --> Visual Studio Tools --> VC

(Alternatively, open a command prompt and set path to MinGW.)

  • Change to directory of your QtJambi clone

  • Set paths:

> set JAVA_HOME_TARGET=path to your java jdk

> set PATH=...\apache-ant-1.10.3\bin;%PATH%

> set QTDIR=C:\Qt\6.0.0\msvc2019_64

Linux and macOS

  • Open a shell and change to directory of your QtJambi clone

  • Set paths:

> export JAVA_HOME_TARGET=path to your java jdk

> export QTDIR=/opt/Qt/5.15.0/gcc_64

All platforms

  • build QtJambi:

> ant all

(This step may take several hours.)

  • optionally, create and run unit tests:

> ant tests.generate tests.run

  • Find unit test results here: build/tests/TestResults-release and build/tests/TestResults-debug.

  • Finally, find all Java libraries in directory deployment and all native libraries in the platform, compiler and configuration specific subdirectory, e.g. win64/msvc2019x64/release.

JDK 1.8 Build

If you want to build Java binaries for JDK 1.8 initially set path to a coresponding JDK in addition to a JDK 11 or higher:

> set JAVA8_HOME_TARGET=path to your java jdk 1.8

or

> export JAVA8_HOME_TARGET=path to your java jdk 1.8

Qt5 Modules

Following Qt5 modules are available in QtJambi:

Qt Essentials

Qt Add-Ons

Platform Dependent Features

Qt3D

Qt6 Modules

Following Qt6 modules are available in QtJambi:

Qt Essentials

Qt Add-Ons

Qt3D