Home · Overviews · Examples 

Installing Qt Jambi

Qt Jambi is available both in prebuilt and source packages for Linux, Mac OS X, and Windows. Java 1.5 or later is required to install Qt Jambi.

The procedure of installing is different depending on whether you have downloaded a source or prebuilt package. This installation guide has separate sections for each approach.

Enjoy !

Installing from a Prebuilt Package

After extracting the package, you are ready to run the Launcher, which is an application that runs the examples and demos that come with Qt Jambi.

To run the examples and demo launcher on Windows run the

    qtjambi.exe

executable from the root directory. On Linux and Mac OS X run the

    qtjambi.sh

shell script from the Qt Jambi directory.

Running these files will verify the virtual machine version and set the correct environment for running Qt Jambi applications. If you later have problems running your own applications, you can examine the script, update the class path, and replace your own class with com.trolltech.launcher.Launcher.

When you are ready to distribute your own applications, see the deployment document.

Manually Launching Qt Jambi Applications

To manually run Qt Jambi, the CLASSPATH environment variable must include the qtjambi.jar file to get access to the library. To run the examples or launcher, the classpath must also include the Qt Jambi directory.

The QT_PLUGIN_PATH variable must contain the path to the plugins directory in the Qt Jambi directory. Qt Jambi will also search for plugins in .jar files to which the system property com.trolltech.qt.pluginjars contains paths.

Finally, Qt Jambi must be enabled to find the native libraries:

PlatformComment
WindowsSet the PATH environment variable to include the bin directory in the Qt Jambi directory.
LinuxSet the LD_LIBRARY_PATH environment variable to include the lib directory in the Qt Jambi directory.
Mac OS XSet the DYLD_LIBRARY_PATH environment variable to include the lib directory in the Qt Jambi directory.

You are then ready to run Qt Jambi applications. For instance, the launcher can be run like this:

    java -jar qtjambi.jar com.trolltech.launcher.Launcher

Note that the -jar option must be given the complete file path to the .jar file.

Building Qt Jambi from a Source Package

This section describes how to build Qt Jambi from source. We first explain how to configure your system, and then we go through the procedure of building Qt Jambi from the command line. Finally, we look at some common installation problems.

Note that a source package requires a Qt installation. On Mac OS X, Qt must be configured without frameworks (by running the configure script with the --no-framework option).

Configuring the System for Qt Jambi

The Jambi source package requires Qt to be installed on the system. The java version must be at least 1.5.

The following table describes the environment variables necessary to install Qt Jambi. We assume that the JAMBI environment variable contains the path to the Qt Jambi directory. The QTDIR variable contains the Qt directory.

QTDIRThis variable must contain the path to the directory where Qt is installed.
JAVADIRThis variable must contain the path to the directory where Java is installed.
PATHThis variable must include the directory JAVADIR/bin.
  • LD_LIBRARY_PATH on Linux
  • DYLD_LIBRARY_PATH on Mac OS X
  • PATH on Windows
This variable must include the directory JAMBI/lib and QTDIR/Lib
CLASSPATHThis variable must include the JAMBI directory.

Building

We will now go through the procedure of building Qt Jambi step-by-step from the command line. We give shell transcripts for all commands necessary to successfully set up a working Qt Jambi environment. The transcripts are given from a Linux shell, but are essentially equal on all platforms; we will point out differences as we go along.

Building and Running the Jambi Generator

The Jambi Generator generates java source files that wrap the Qt C++ libraries. In order to build Jambi itself, we need the generator. So go into the directory in which it lives:

    cd $JAMBI/generator

Then run qmake and the make tool on your system (On windows the tool is usually gmake or nmake):

    qmake
    make

Then run the generator. Default settings are fine, so no command line arguments are necessary:

On Linux:

    ./generator

On Windows:

    release\generator

The generator will give several warnings while running. This is normal and does not present a problem.

Building C++ libraries and tools

Go back to the JAMBI directory and run qmake to generate the necessary make file. Finally, build with make:

    cd ..
    qmake -r
    make

Generating Ui files

We now need to build the Ui files, i.e., create java files from UI created with the Qt Designer:

    ./bin/juic -cp .

Building the Java Source Files

The generator and juic have now created the Java source files for Qt Jambi. These are all listed in the file java_files. The Java compiler javac can take this file as an argument and will then compile all sources.

    javac @java_files

Note that on some systems it might be necessary to invoke javac with the VM option -J-mx1024m to prevent the VM from running out of heap space; you may need to choose a different heap size than 1024.

Running Qt Jambi Applications

After building Jambi, you should add the JAMBI directory to the class path. Then Qt Jambi applications can be run, for instance the Launcher:

    java com.trolltech.launcher.Launcher

If Qt was built with debugging turned on, you need to use the Qt Jambi debug libraries. You specify this with the com.trolltech.qt.debug system property.

Note that on Mac OS X, the VM must be invoked with the -XstartOnFirstThread option.

Trouble Shooting

If you have trouble compiling and running Qt Jambi, we present problems that are commonly encountered in a table. This should be sufficient to solve most problems; failing that, try asking someone. The Jambi FAQ is a good place to start. In the Jambi Mailing List, active Jambi users and the Jambi development team can be helpful with installation problems; please run Qt Jambi with the com.trolltech.qt.verbose-loading system property and give stack traces if Qt Jambi fails to load native libraries.

Common Problems

In this section, we have tried to gather common problems encountered while building Qt Jambi. They are listed in a table with columns for the problem description and solution.

ProblemSolution
On Linux the gcj (GNU Java Compiler) is located in /usr/bin; the path to the correct java version must be before this in the PATH. This usually results in java.lang.ClassFormatError errors.Make sure that it is the correct java executable in the PATH.
Environment variables are not set correctly.Check with the Configuring the System for Qt Jambi section that your system is properly configured for Jambi.
Qt Jambi uses the Qt Header files to generate the mapping from c++ to java. Unless Qt was built with default settings, you may get link problems for bindings that are not in the native libraries.Build Qt with default settings
juic does not update .juic files that are not modified, which can be a problem if Java sources are deleted.Run juic with the -a option.
Qt Jambi expects that Qt was built with debugging turned off. If Qt was built with debugging, the libraries will not be found.Run Qt Jambi with the com.trolltech.qt.debug system property.

Load Issues

If Jambi cannot find the native libraries, you will get java.lang.UnsatisfiedLinkError's or other load issues. The search paths - in the order Jambi searches - for libraries are listed below.

Jambi will tell which libraries fail if you run java with the -Dcom.trolltech.qt.verbose-loading=true command line argument. You can then check if the library is in one of Jambi's search paths. Note that Jambi will report on each attempt to load a library.

Jambi depends on a few common system libraries. Notably, Xinerama on Linux, which may be missing on older systems. Information about such missing libraries are not propagated from the operating system to Jambi; how missing libraries are reported may vary from system to system.

Platform Notes

PlatformComment
Mac OS XWhen running a Qt Jambi application, it is necessary to pass the -XstartOnFirstThread argument to the Java executable. Also, if you have a source package, you have to build Qt with the --no-framework option.
Linux / 64 bit:Install a 32 bit virtual machine, e.g., on Ubuntu, install the ia32-sun-java5-bin package and put /usr/lib/jvm/ia32-java-1.5.0-sun-1.5.0.06/jre/bin into the PATH environment variable.

Running the Qt Designer

The Qt Designer is Trolltech's tool for designing and building user interfaces. If you have a prebuilt package, you can run it from the command line with the qtdesigner.bat or qtdesigner.sh scripts. The Eclipse integration handles the designer automatically.

You will find more information in the Qt Designer document.

Running the Qt Jambi Generator

The generator is a Qt application which can be used to map C++ based Qt APIs onto equivalent Java APIs. The Qt Jambi package provides an example on how to use the Qt Jambi Generator, located in the path/to/Qt Jambi/generator_example directory.

To generate the example's Java library run the

    generator_example.bat

script on Windows. On Linux and Mac OS X run

    generator_example.sh

These scripts will generate and compile the Java source code, as well as compile the C++ side of the example. See the script files for details.

Warning: The Qt Jambi generator is written to handle Qt based source code, and is not intended for mapping C++ libraries in general.


Copyright © 2007 Trolltech Trademarks
Qt Jambi 4.3.2_01