The Source for Java Technology Collaboration


Integration With Native Linux Desktops

Developers should take a look at thenice article by Joshua Marinacci about JDesktop components: http://today.java.net/pub/a/today/2004/10/14/jdic1.html

We Java developers strive to get WORA apps (Write Once, Run Anywhere). But users of desktop apps want seamless integration with their desktop of choice, which usually means Gnome or KDE, but don't forget WindowMaker, IceWM, Xfce and others. At least, they want to see lauch icons on the desktop, menu itens, and file associations.

It's perfectly possible to get these and remain 100% Pure Java. Most can be done with a customized installation procedure, that changes the relevant (plain text) configuration files. The installer can even be 100% Java itself. But sometimes you'll need more: panel applets, components for use inside other (native) apps, desktop themes...

Java 1.4.2 provides a Gnome look and feel that could inherit the look and feel from most popular theme engines, for example Red Hat Blue Curve. I've never got this to work except with simple Swing demos. Sad that many big Java apps force the Metal look and feel at startup (maybe because they use too much null layouts). But others, like NetBeans 3.5.1 and ArgoUML 0.12, simply crashed on my tests. frown (But recent releases, NetBeans 3.6 and ArgoUML 0.14, worked fine with alternate LAFs. Sad the "native" GTK LAF doesn't works, even the one included on Java 1.5.0 Beta1/2)

There is a third-party Swing look and feel that tries to emulate Gnome (GTK): http://gtkswing.sourceforge.net. But it only supports the default GTK theme. Sory, I could not find a KDE (Qt) laf. Some third-party plug-ins tries to use Gnome and KDE themes, but I could not find anyonw which works out-of-the-box, all them seem to need you to point them to the theme files and call configuration APIs, so they are useless unless you can patch and recompile the application.

There are several initiatives which could be considered to provide better native integration with the Linux desktop, and none of them are LAFs for Swing. The best of them in this author's opinion [trejkaz, not flozano -- see his opinion bellow] is the following:

  • wx4j (http://www.wx4j.org/) is a Java binding for the popular wxWidgets (http://www.wxWidgets.org/) widget proxies. wxWidgets is a cross-platform wrapper for native widget APIs, and thus while you get a nice, fast, native-looking GUI on Linux, you also get native-looking GUIs on Windows, Mac, and any other system which wxWidgets might be ported to in the future. The primary advantage of this is that only a single wrapper needed to be made to achieve cross-platform support, since all the cross-platform work has been done once before (and why do it all again?)

wx4j's only problem in this author's opinion is that the API follows the original wxWidgets naming scheme. Therefore the frame class is org.wxwindows.wxFrame, whereas to be more correct it should be org.wxwidgets.WxFrame. Also it has the same issue with uppercasing the start of method names, which is a no-no in Java as well. If they ironed these out it would be a lot easier to stomach.

Failing that, there are still other options which come to mind:

  • SWT, which I'm sure you all know about as the API behind Eclipse. I won't go into it but it's not entirely bad. Just needs to look more native, things such as tabbed interfaces could be better. [trejkaz opinion on SWT does not look very favorable, but Eclipse proves SWT is mature and has good performance. It also allows you to embeb Mozilla for displaying HTML content]
  • QtJava and KdeJava are part of KDE's kdebindings package, and provide direct access to the Qt and KDE APIs from Java. There is also an API for getting access to dcop, which is KDE's interprocess communication system.
  • Java-Gnome (http://java-gnome.sourceforge.net) is a Java binding to the Gnome APIs based on JNI. It's not complete yet, but already provides most GUI widgets, so you Java app can look native in any Gnome theme and will support advanced features like Pango and Bonobo. So, Java-Gnome custom widgets will be usefull with native Gnome Apps developed using C or Python. As an extra you'll get better performance than Swing and even SWT.

Of these, SWT has got the biggest momentum, but Java-Gnome is the better on a performance viewpoint. After all, wxWindows and SWT will be a just layer over GTK on Linux. But none of them uses GTK Gadgets (windowless components), they have to map each Control to its own native window. That's the price for a cross-pataform native GUI API. Java-Gnome has been accepted as part of the official Gnome bindings, so it'll became standard on every Linux distro. And let's remember you can use GTK on other OSes than Linux, as Gimp ports for Windows, Mac and OS/2 shows.

So IMHO (flozano) Java-Gnome would be the first choice for a Linux developer, followed by SWT. wxWindows come third, and KdeJava? follows. Please, KDE deveopers/users, don't flame me. wink The fact is that Qt and KDE APIs were not meant to support programming languages other than C++, while GTK was created from start to be language-agnostic.

It is important as always to remember that not everyone runs the same desktop environment as yourself. If you use KdeJava?, make it optional. If you use bits of the GNOME API other than GTK+, make those optional too. People don't take kindly to requiring big libraries which they can't use. smile

Original by: -- Main.flozano - 23 Jan 2004

Updated with more APIs by: -- Main.trejkaz - 29 Apr 2004

Updated with clarifications on opinions and new info about Java-Gnome by: -- Main.flozano - 28 Jul 2004

Updated with link to article about JDesktop -- Main.flozano - 18 Oct 2004

Topic IntegrationWithNativeLinuxDesktops . { Edit | Ref-By | Printable | Diffs r5 < r4 < r3 < r2 < r1 | More }
 XML java.net RSS

Revision r5 - 18 Oct 2004 - 22:11:43 - Main.flozano
Parents: WebHome