Can you access C++ classes from Java ?
Hi,
I have a C++ library which I want to use from my Java
code.
I have looked at the tutorial on JNI and can see how to
call C++ methods, but I'm told I need to be able to
instantiate and interrogate classes from the C++ library
in order to use it.
Is there a way of doing this please ?
Cheers
Sue
[369 byte] By [
suew2] at [2007-9-26 14:00:10]

You have to write JNI c functions which then call your C++ member functions. These obviously must take similar parameters to those in the C++ class. You need to write a JNI function which will call new on your C++ class.
It is rather tedious writing all this code, but there is an easy way. Use SWIG (www.swig.org). This is a very powerful tool which you give your C++ header files and it writes all the JNI wrapper functions in C and proxy Java classes to access your C++ class.
Guest at 2007-7-2 15:09:41 >
