You can also use the C$SOCKET library routine to facilitate interprocess communication between Java and COBOL programs via sockets. C$SOCKET is a low-level option, but it is very flexible.
When calling Java from COBOL:
Of course, because the data format is totally open and undefined, the COBOL and Java programmers must agree on a common format.
The following sample code demonstrates this capability:
*Create a Client Socket. CALL "C$SOCKET" USING AGS-CREATE-CLIENT, 8765, SERVER-NAME GIVING SOCKET-HANDLE. *Write data to socket. CALL "C$SOCKET" USING AGS-WRITE, SOCKET-HANDLE, DATA-FROM-CLIENT, DATA-LENGTH. *Read the return data from the socket. CALL "C$SOCKET" USING AGS-READ, SOCKET-HANDLE, DATA-FROM-CLIENT, DATA-LENGTH. *Close the socket. CALL "C$SOCKET" USING AGS-CLOSE, SOCKET-HANDLE.
See C$SOCKET for complete information on the C$SOCKET library routine.