Search code examples
javagnucobol

Invoke Java class from GnuCobol


Apologies if this question has been asked previously... I'm working on a proof of concept which requires GnuCobol(opencobol) to call/execute a Java class. Googling through a number of pages suggested use of INVOKE statement by instantiating the Java class. Unfortunately INVOKE is yet to be supported in GnuCOBOL. Any pointers on how the integration could be achieved will be very much appreciated.

Thanks


Solution

  • Moving a comment to an answer, for completeness.

    You probably want to look at JNI. GnuCOBOL uses the C application binary interface, so the Hello world example on Wikipedia for JNI should have all the hints you need to get started. If you are lucky enough that the classes are AWT related, then COBJAPI is the thing to bing google for. The C code that SWIG generates is also directly callable by GnuCOBOL, so it's another path and will, at the least, give you a good set of skeletal files to work from.