[Kde-java] Re: [Kde-bindings] JNI library names

Richard Dale Richard_Dale at tipitina.demon.co.uk
Tue Mar 30 08:55:02 CEST 2004


On Monday 29 March 2004 14:48, Dominique Devriese wrote:
> Richard Dale writes:
> > On Monday 29 March 2004 10:11, Dominique Devriese wrote:
> >> Hi,
> >>
> >> I have a question about the naming scheme of the JNI libraries in
> >> kdejava and qtjava.  Apparently, gij expects them to have a name
> >> like "lib-org-kde-qt.la", instead of the current libqtjava.la.  Am
> >> I misinterpreting something, or should they really be renamed ?
> >
> > lib-org-kde-qt.so is a different library to libqtjava.so, it is just
> > the interfaces in qtjava.jar compiled to a library. You still need
> > libqtjava.so as well.
>
> Sorry, can you explain this to me ?  AFAIU, the idea behind JNI is
> that you make a few class files which have some methods declared
> "native", and for each of these methods, a C function is created with
> a name derived from the java method name.  IIUC, these C functions are
> defined in libqtjava.so.  Now what I'm not sure about is how the java
> vm is supposed to find the library in which these C functions are
> defined.  I assume it looks for a library name like
> "lib-org-kde-qt.la", is this not correct ?
No, that libary is loaded in qtjava.java with a System.loadLibrary() call:

	public static void initialize() {
		if (!_initialized) {
			System.loadLibrary("qtjava");
			qtjava.registerJVM();
			qtjava.setJavaSlotFactory();
			qtKeyToJavaMap = new WeakValueMap();
			qtSignalDictionary = new HashMap();
			qtSlotDictionary = new HashMap();
			_initialized = true;
		}
	}

The name "qtjava" will map onto a library (or dll in Windows).

> Anyway, the reason I'm asking this is because I have some debian
> packages built, but they're unusable, because the gij interpreter
> complains about a NoClassDefFoundException when trying to load the
> qtjava class.  I strace'd the process to see what it was trying to do,
> and it opened the qtjava.jar file fine, and then started looking for a
> library with a name like "lib-org-kde-qt.la".  I assumed the JNI lib
> was misnamed.
I'm not sure why it would do that - I thought it looked for the library first 
and used it in preference. You should just need qtjava.jar on the classpath, 
and libqtjava.so on the library path, and it all should be fine.

> > But the combination of lib-org-kde-qt.so and lib-org-kde-koala.so is
> > so large that the memory occupancy of a simple program I tried went
> > up from 25 Mb to 50 Mb. If gij finds a library lib-org-kde-qt.so it
> > will use it instead of qtjava.jar, so it really extends the idea of
> > .jar files/classpaths to work with libs too.
>
> Oh, so this "lib-org-kde-qt.so" library is the gcj-compiled "native"
> version of the classes.  But how then is gij supposed to find the
> library in which the JNI functions are defined, and why won't it run
> my test app ? :)
Is libqtjava.so on your LD_LIBRARY_PATH? What error are you getting - is it 
the same NoClassDefFoundException that you describe above?

-- Richard


More information about the Kde-java mailing list