Qtopia Home - Classes - Hierachy - Annotated - Functions - Qt Embedded |

## Qtopia - Java Integration

When integrating a Java VM into Qtopia, it is important for the end-user that installed Java applications operate seamlessly along with native Qtopia applications. To ensure this, the following considerations should be made. These items are listed in order of the Qtopia aplication execution control flow and so correspond to the order in which they can be easily tested.

- Use .desktop files

  Like native Qtopia applications, Java applications should be referenced by .desktop files in the $QPEDIR/apps/Applications or $QPEDIR/apps/Games directory (depending whether it is an application or a game); they should not be boxed off into a seperate tab, or in a wholy different interface.

- Use unique executables

  In order that Qtopia's execution model works, the Exec= line of the .desktop file should specify a unique executable name. Of course, this executable name may simply be a symbolic link to the actual executable which then uses argv[0] to determine its behaviour. This is essential for QCop communication between the application and the launcher. In particular, it will not work to use "Exec=jvm appname".

- Use QPEApplication

  You must use QPEApplication, not QApplication, otherwise all of the framework provided for Qtopia will not function. In particular, QPEApplication communicates with the launcher via QCop to handle things such as the taskbar icon, raising, quitting, openning documents, and changing styles and fonts.

- Use QPEApplication::exec()

  This ensures that various things such as QCop processing is initiated. If you must use your own event loop rather than exec(), you must at least call QPEApplication::setMainWidget(). If even this is not possible, additional functionality will need to be added to QPEApplication to support your event loop.

- Follow Qtopia Conventions

  The widget toolkit or bindings used by the JVM should wherever possible follow Qtopia's conventions. For example, it should use QPEApplication::execDialog() rather than QDialog::exec().

The above rules can all be bent to various degrees, but that will involve additional integration coding in QPEApplication and in the Qtopia launcher (qpe) process.