Legacy Code (C) to Java
1 posts in topic
Flat View  Flat View

Posted By:   Rashid_Kamain
Posted On:   Tuesday, March 19, 2002 10:42 AM


I am new to JNI, and would appreciate any help. I am trying to create Java wrappers for legacy C code. I can write the java classes calling the native functions and the .h file as well. However, my question is: do I have to edit and recompile the legacy code based on the headers from the .h file? What if I dont have access to do that, how would I go about implementing Java wrappers in this situation? Thanks!

Re: Legacy Code (C) to Java

Posted By:   Panayiotis_Alefragis  
Posted On:   Wednesday, March 20, 2002 05:30 AM

There is a tool called swig (http://www.swig.org) that can even create the java classes by reading the
C/C++ header files.

And for your question about recompilation. NO!!!. Just create a shared library, based on the JNI, that makes calls to the legacy library and takes care of the translation from/to the Java/C structures. Then use this library from Java and you are finished.

Hope I helped.


About | Sitemap | Contact