[Kde-bindings] Kdejava in Eclipse

Richard Dale Richard_Dale at tipitina.demon.co.uk
Wed Apr 28 02:07:40 UTC 2004


On Tuesday 27 April 2004 23:37, James Ots wrote:
> Hi,
>
> I've just written and run my first Kdejava programme. Took me a while
> though. First I had to compile the bindings since SuSE don't supply updated
> bindings with KDE updates. Then I had to work out how to get java to pick
> up libqtjava.so and libkdejava.so. That was the hard part.
Yes, I'm afraid there isn't much documentation other than the READMEs. The 
javadoc looks pretty good - I use it in preference to the C++ api docs.

> From the shell I could either add /opt/kde3/lib/ to LD_LIBRARY_PATH, or add
> -Djava.library.path=/opt/kde3/lib to the java command line. But when I
> tried to run it from inside Eclipse 3.0M8, it could never find qtjava,
> despite trying nearly every way I could think of for telling it how to find
> it. Eventually I copied the .so files into $JAVAHOME/jre/lib/i386, and it
> worked. Is there a better way to do this?
You can add the path to /etc/ld.so.conf and run ldconfig to add it to 
/etc/ld.so.cache.

> I also noticed that KMainWindow.menuBar() returns a QMenuBar rather than a
> KMenuBar. I expect it's documented somewhere, but I haven't found it yet.
> Why is this?
Because java 1.3 or so doesn't have covariant return types, it can't return a 
KMenuBar because in the superclass QMainWindow.menuBar() returns a QMenuBar. 
So menuBar() and statusBar() needed to be special cased to return the same 
type as the parent. A work round would be to use Qt.dynamicCast():

KMenuBar myMenuBar = Qt.dynamicCast("org.kde.koala.KMenuBar", 
kMainWindow.menuBar());

Or perhaps the menuBar() and statusBar() methods should be renamed like this:

	/**	
		 Returns a pointer to the menu bar.
			 If there is no menu bar yet one will be created.
				@short    Returns a pointer to the menu bar.
	*/
	public native KMenuBar kmenuBar();
	/**	
		 Returns a pointer to the status bar.
			  If there is no
		 status bar yet one will be created.
		     		@short    Returns a pointer to the status bar.
	*/
	public native KStatusBar kstatusBar();

I was about to check this in to the release branch, but I'm not sure if it 
isn't better to leave the names as they are, and do the cast as above. Which 
is the lesser of the two evils? hmm..

> Anyway, I'm now trying to think of a killer app to write using Kdejava...
Well good you've got it working, happy java hacking!

-- Richard



More information about the Kde-bindings mailing list