I would like to have a KJavaAppletWidget class. This would be a C++ class that extends QWidget and displays a Java applet. The class would hide the details of the communication between Java and C++, and would have a fairly trivial API for users. Once such a widget exists adding Java applets support to an application would be trivial - the problem of course is how to write the widget...
I can see two main approaches: one is to use the Java invocation API
to load a JVM into the process of the application, the other is to have
a Java server that runs in a separate process. I'll refer to the first
as 'in-process', and the second as 'out-of-process'.
| In process | Out of process |
|---|---|
| Have to contend with threading issues | No threading problems |
| JVM crash will kill KFM | JVM crash easy to handle |
| JVM load may block UI | No problem |
| JVM cannot be unloaded | JVM unload by killing child process |
| Fairly easy to communicate with the JVM (JNI) | Need custom communication mechanism |
I think the out of process design is better, the main difficulty is the communication between the application and the embedded applet. Displaying the applet window inside a KJavaApplet widget is fairly easy to achieve using swallowing.
Things the application sends to the applet: