[kaffe] Portable Java GUI

Chris Gray chris.gray at kiffer.be
Mon Mar 1 15:22:05 PST 2004


On Monday 01 March 2004 20:20, Dalibor Topic wrote:
> Hallo Volker,
>
> Volker Jahns wrote:
> > Is there any recommendations out there, what to use other than Swing to
> > code  a _real portable_ Java based GUI (using eg. Kaffe's jvm)? I am
> > looking for a Java class, which doesn't use much space (no bloatware) and
> > is distributed under some form of Open Source license.
>
> That depends on how far you want 'portable' to stretch. AWT is part of
> all Java releases from Sun since JDK 1.0, but you don't want to use 1.0
> AWT unless you have to ;) 

JDK 1.0 and 1.1+ AWTs are also so grossly incompatible that the only 
practical way to code a GUI which works on both is probably to somehow detect 
which version you're running on and then branch into one of two disjoint 
implementations. Barf.

> Kaffe and Wonka, among free runtimes for java,
> have got pretty complete AWT support, gcj & other GNU Classpath based
> runtimes are catching up quite quickly. Given the recent progress gcj
> developers are making on Swing, I'd say that even a free swing
> implementation is possible within a reasonable time frame. but Swing is
> only available since JDK 1.2 (or JDK 1.1.7 + external swing.jar).

I'd love to be proved wrong, but I fear that Swing is inherently 
resource-intensive.  For "closed" applications gcj may be able to generate 
non-bloated code by sheer genius :), but I fear that in the general, 
dynamically resolved and loaded case Swing will always be a monster.

> >>From my little experience (now that a first Java prototype using Swing
> >
> > components has been coded) it is rather a pain to get that GUI code
> > running on platforms/jvms other than using Sun's newest J2SE, version
> > 1.4.1 or 1.4.2. Thus, while the promised platform indepency of Java is
> > claimed, practice seems to far off this goal.

Targeting 1.4.1 or 1.4.2 works today; tomorrow 1.5 will be released and the 
"standard" will have changed again.  This is surely not the way.

> Depending on how far you want portability to stretch, you can get very
> nice results using bindings to native code cross platform GUI libraries,
> like Qt, Gtk and SWT. Since those bindings usually just use JNI, they
> run fine on most free and non-free runtimes alike. Another way is to
> abstract the GUI away into an XML representation, and generate
> platform-specific code form that. XUL, Luxor, XWT go in that direction.
> I haven't played with either of them, so I can't say how well they work
> with free runtimes.

Where the GUI is to be co-located with the VM, native libraries such as Gtk 
look like a good choice.  The XML-based ones are especially interesting if 
the UI may be located somewhere else (touchscreen with own CPU, handheld 
device, etc.).

Otherwise, just go with good ol' AWT 1.1.x, for values of x close to 7.

Good luck

Chris

-- 
Chris Gray                                  /k/ Embedded Java Solutions
Embedded & Mobile Java, OSGi              http://www.kiffer.be/k/
chris.gray at kiffer.be                                      +32 3 216 0369




More information about the kaffe mailing list