Reading COBOL datastructures from Java

There appear to be some commercial solutions for this. Alternatively you can use cb2xml to convert the copybooks to XML, and then import the XML into Java using whatever mechanism you require.


You could look at JRecord or cb2java. Both allow you to access COBOL files, but neither will generate the full classes.


Update Jan 2011

Since the original answer:

  • JRecord continues be developed. There is now a JRecord Code generator available as either a standalone program or in the Recordeditor. This Code Generator will build JRecord JRecord code from a COBOL Copybook. See RecordEditor Jrecord CodeGen)
  • Development on cb2java has stopped
  • cobol2j has been written. There have been no updates for a year.
  • There is also Legstar again nothing published for a few years

Update Aug 2017

The RecordEditor has a Generate option for generating Java / JRecord code from a COBOL Copybook. See RecordEditor Code Generation notes for details.

Update Jan 2018

There is some information on generating Java~JRecord code in this question / answer:

How do you generate java~jrecord code for a Cobol copybook


Yes. I have done that before. I used an ODBC connection to COBOL files, and then with jdbc:odbc bridge, I used metadata information to generate classes, read data and port it all to Oracle.

Here is a nice tutorial on how to access metada information with JDBC. Here is another one.

Keep in mind that you don't need the JDBC:ODBC bridge approach. If you can get a native JDBC driver to connect to your Cobol DataSource, it will be better. In this regard, I also used an IBM native driver. Don't remember the name though. It was a long time ago.