PDA

View Full Version : Qt <-> Java - Best Practices?



mentat
18th July 2006, 15:53
Hello All-

I have a project that I expect to have to integrate some java code with Qt code. The question is whether or not there is some neat Qt trick to do this, or should I just go through "standard" processes of calling methods back and forth? If so, are there standard practices other folks here use? I did some googling around and it seems that there are a number of ways to do this in the general C++<->Java manner. Any hints as I go down this unfortunate path?

Thanks!

-Lance

wysota
18th July 2006, 16:05
I suggest you wait a little as Trolltech is preparing Java bindings for Qt, which would surely make your life much easier.

mentat
18th July 2006, 16:14
I suggest you wait a little as Trolltech is preparing Java bindings for Qt, which would surely make your life much easier.

Thanks for the info! I was hoping for that. Unfortunately, for the proof-of-concept I'm putting together, I'll need the bindings sooner rather then later - so I guess standard C++<->Java methods will be the way to go for now. Do you know how long we'll have to wait for these bindings (ie: are we talking weeks, months, or unknown)?

Thanks!

wysota
18th July 2006, 16:33
I think there are some 3rd party Java-Qt3 bindings available (http://sourceforge.net/projects/qtjava). As for Qt4 bindings from Trolltech, they didn't specify any release date, but I think it'll be in Q4 this year (but that's my personal wild guess, no warranties given).

mentat
18th July 2006, 18:41
I think there are some 3rd party Java-Qt3 bindings available (http://sourceforge.net/projects/qtjava). As for Qt4 bindings from Trolltech, they didn't specify any release date, but I think it'll be in Q4 this year (but that's my personal wild guess, no warranties given).

Thankfully, I don't really have to worry about GUI/Window stuff. It's really just "execute this function", "execute that function" kind of stuff. I do want to make the Java code work as a QPlugin, so I'll need to build some wrapper code for this functionality. I'm playing with that now.

QiT
19th July 2006, 18:35
Hi

You can use JNI to interface qt <--> c++ <--> java.
For more information google->JNI TUTORIALS:D

mentat
20th July 2006, 03:32
Well it was easier said then done in the search for call Java from C++. Java folks can't imagine that anyone would actually write a C++-based program that would call a Java routine or two. Almost every source I found would always say something along the lines of JNI is for those times when you don't have time to port a native routine to Java. I even found a forum site that answered my C++->Java question by honesty suggesting that the person should re-write the code in Java because Java is "better." Talk about a poor response to a good question! Anyway, it took a lot of searching to find a simple "Hello World"-type example, but here are few for other developers who may have the same question as I.

http://www-128.ibm.com/developerworks/linux/library/l-pow-jniexamples.html

http://www.inonit.com/cygwin/jni/invocationApi/