I wrote my first Jambi program today (That's Qt for Java, btw). I admit to being one hard core C++ developer, but having nothing against Java as a language... as opposed to its horrible APIs. Which is also why I've shyed away from Qt Jambi, making little sarcastic remarks to those of my colleagues that have done all the work implementing it. But I coincidentally found myself in a situation where I was forced to write a Jambi application. Or rather, port a C++ application to a Jambi .java file. And uhm, I guess you can say I was positively surprised. :-)
My First Qt Jambi app, showing perspective transformations using Graphics View.
Since let's face it, beyond the difference in syntax there's nothing very different between these two languages (that I care about anyway). Now I am a C++ enthusiast, but I do still think garbage collection is nice sometimes [*], although _constantly_ having to "new" everything is somewhat annoying, just look at the source at the bottom of this post. Native C++ generates library files that need to be in LD_LIBRARY_PATH or somehow known to the runtime when you launch your app. And likewise, Java apps need to know their .jars and .class files. But language details is really not the issue when I choose a tool for a job.
I downloaded the Jambi Linux32 GPL OpenSource package from ftp://ftp.trolltech.com/qtjambi/source, and unpacked it into my home directory as /home/ahanssen/qtjambi-linux32-gpl-4.3.1_01. With some help from Eskil, who pointed out that the package contains a .jar file that basically is all you need to worry about, I spent about 15 minutes porting my app to Jambi. Why so long? Well, because there are a few things the fresh Jambi developer needs to know about what the Qt API looks like in the Java world. And (chuckle) I was too lazy to look up the complete docs at doc.trolltech.com. They even made JavaDoc documentation. Awwww... ;-)
Where C++ uses namespacing with ::, Java uses a '.' instead.
For enums, you need to include the name of the enumerator like this: Qt.Orientation.Horizontal.
Java doesn't understand a->b ;-), hehe. Just search & replace your "->" with "." right away.
Typically all qualifiers for function args go away. So "const QRectF &" becomes "QRectF".
There's no stack-allocation, so setPen(QPen()) becomes setPen(new QPen()).
Qt Jambi uses Java's native types, so instead of qreal, etc, just use double.
I encourage you to try it out, it's really easy. And it _is_ Qt. To run my Jambi program, all I did was type this into my console: