Giter Site home page Giter Site logo

dividetoinfinity / qtjambi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from omixvisualization/qtjambi

0.0 0.0 0.0 35.02 MB

QtJambi is a wrapper for using Qt in Java.

Home Page: http://www.qtjambi.io

License: Other

C++ 47.94% C 0.58% Java 37.41% Objective-C++ 0.01% HTML 0.01% QML 13.83% QMake 0.24% Batchfile 0.01%

qtjambi's Introduction

QtJambi - Java Bindings for Qt

QtJambi - Java Bindings for Qt

Overview

QtJambi is Qt bindings for the Java programming language originally developed by Trolltech, the predecessor of The Qt Company. The successive open source project provides bindings of Qt5 and Qt6 releases for latest Java JDK versions.

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 QtJambi would simply add the coresponding Java libraries (.jar files) to their Java project to be able to develop and deploy their application.

Availability

Maven Central Release (latest by date) GitHub Sponsors

QtJambi is available for Java 8 or 11 and higher using Qt5.15 and Qt6 in Java on Windows, Android Linux and macOS. Most Qt modules are available as QtJambi module as listed here. All modules are published as Maven Artifact.

Support

QtJambi is an open source project making the power of Qt available for your Java projects free of charge. However, this project is causing ongoing costs. Please consider supporting this project by donation. Your support is highly appreciated.

Sponsor this project

How To Build From Sources

If you just want to use QtJambi for your application development you can skip these instructions and simply use the provided binaries from the list of modules. 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 18)
  • Qt 5.15 or 6.x (using the Qt Online Installer)
  • Minimum required Qt modules: QtCore, QtQml, QtNetwork, QtConcurrent and QtXml
  • C++ compiler and make (Gcc, Clang, MSVC2019)
  • XCode command line tools (macOS only)

Building QtJambi

If you do'nt need the entire set of Qt modules available in Java edit property qtjambi.skipped.modules in build.properties and exclude Qt modules you don't need. This saves compilation time. Although QtJambi build process requires the availability of QtQml, QtNetwork, QtConcurrent and QtXml, you can skip them from being generated as QtJambi module.

Pre-Build Steps On Windows

  • Open the Visual Studio command prompt for x64 architecture.

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

  • 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.5.0\msvc2019_64

Pre-Build Steps On 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/6.5.0/gcc_64 on Linux

> export QTDIR=/opt/Qt/6.5.0/macos on macOS

Building Bindings

  • 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 in directory TestResults.

  • Finally, find all Java libraries in directory $VERSION/deployment and all native libraries in platform- and configuration-specific subdirectory, e.g. native/windows-x64/release.

Cross-Compilation

After building QtJambi for the running operation system you can additionally cross-compile QtJambi for other platforms. For instance if you want to build for Android use the following command (on Windows):

> ant -Dqmake=C:\Qt\6.5.0\android_x86_64\bin\qmake.bat library.native

or if you want to build for Linux arm:

> ant -Dqmake=/opt/Qt/6.5.0/arm-gnueabi/bin/qmake library.native

Just specify the third-platform cross-compiled qmake with -Dqmake=path.

How To Use QtJambi

Example

Add qtjambi-VERSION.jar to the classpath of your Java project containing the most essential Qt Core, Gui and Widgets modules. If you use Maven to build your application simply add following dependency to your project:

<dependency>
  <groupId>io.qtjambi</groupId>
  <artifactId>qtjambi</artifactId>
  <version>$VERSION</version>
</dependency>

(exchange $VERSION either by 5.15.14 or by 6.5.0).

Otherwise, download QtJambi JAR file from Maven Central Repository.

Create a file Test.java containing the following code:

import io.qt.widgets.*;
public class Test {
    public static void main(String[] args) {
        QApplication.initialize(args);
        QMessageBox.information(null, "QtJambi", "Hello World!");
        QApplication.shutdown();
    }
}

Compile the file:

javac -cp qtjambi-6.5.0.jar Test.java

Execute Example

For execution you need the platform dependent binaries of QtJambi either as self-extracting bundle or as library file (e.b. dll). For instance, if you are working on Windows download qtjambi-native-windows-x64-VERSION.jar from Maven Central Repository and add it to java class path. Additionally, you need Qt. Use the Qt installer to install Qt on your system. Make sure you are using the same Qt version and QtJambi version (e.g. 5.15 or 6.x).

When running a QtJambi application you have to make the locations of Qt libraries known to Java. Therefore, use the PATH environment (LD_LIBRARY_PATH on Linux, DYLD_LIBRARY_PATH on macOS) or the Java runtime property java.library.path. By default, on Windows Qt libraries are located in bin directory and on Linux and macOS in lib directory. In case your Linux distribution provides Qt (of correct version) as system library you don't need to specify library path.

The example program can be executed this way on Windows:

java -cp qtjambi-6.5.0.jar;. -Djava.library.path=C:\Qt\6.5.0\msvc2019_64\bin Test

On Linux it looks this way:

java -cp qtjambi-6.5.0.jar:. -Djava.library.path=<path to>/Qt/6.5.0/gcc_64/lib Test

On macOS you additionally need to use the start parameter -XstartOnFirstThread:

java -cp qtjambi-6.5.0.jar:. -Djava.library.path=<path to>/Qt/6.5.0/macos/lib -XstartOnFirstThread Test

In general, you can start learning how to use Qt in Java as it is introduced for C++. There are a couple of specifics for QtJambi that are introduced here. Instead of starting your program with a java command as shown above you can deploy your application as executable as described here.

Licenses

            GNU LESSER GENERAL PUBLIC LICENSE

 QtJambi is Copyright (C) 1992-2009 Nokia. All rights reserved.
            Copyright (C) 2009-2023 Dr. Peter Droste, 
                                    Omix Visualization GmbH & Co. KG. 
                                    All rights reserved.

 You may use, distribute and copy QtJambi under the terms of
 [GNU Lesser General Public License version 2.1](LICENSE.LGPLv21).
            GNU GENERAL PUBLIC LICENSE

 QtJambi is Copyright (C) 1992-2009 Nokia. All rights reserved.
            Copyright (C) 2009-2023 Dr. Peter Droste, 
                                    Omix Visualization GmbH & Co. KG. 
                                    All rights reserved.

 You may use, distribute and copy QtJambi under the terms of
 GNU Lesser General Public License version 3. That license references
 the [General Public License version 3](LICENSE.GPLv3). Other
 portions of the QtJambi may be licensed directly under this license.

Further Reading

qtjambi's People

Contributors

mchistovib avatar omix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.