Visual Cobol Sample With Java

[Migrated content. Thread originally posted on 04 February 2011]

i dont find an sample in Visual Cobol
with Cobol and Java.

There are in VisualCobol download this sample or not?
  • Sorry, but currently no example exists in the product for calling between Java and Visual COBOL programs.

    The "how to do this" is documented in the Visual COBOL Help under:
    Java and COBOL
  • Verified Answer

    I converted the cobolArray example from Net Express 5.1 to work under Visual COBOL.
    This shows how to use Java to call COBOL entry points and pass data back and forth.

    If you would like this example please post your e-mail address and I will send it to you.
  • Chris,

    I am interested in this example. Could you please mail it to


  • Hi Wilco,

    I sent the demo as requested.

    I had to change the name of the .zip file to .txt to allow the attachment to be sent.
    Please save it back as .zip when you receive it.

  • Chris,

    In addition to your README.txt

    i got errors trying to javac the *.java. The english translation of the dutch text is: Javac is not recognised as internal or external command/instruction.
    I solved this problem by editing my classpath:
    ro Focus\Visual COBOL 2010\bin\mfcobol.jar;
    As you can see the mfcobol.jar was included in the classpath.

    I also included the path to the javac-module in my environment variables.
    (C:\Program Files\Java\jdk1.6.0_21\bin)

    The next problem I faced was that my Java.exe was located under C:\Program Files\Java\jre6\bin\java.exe instead of the C:\Program Files (X86)\Java\jre6\bin\java.exe as referenced in the project.

    I hope you can add these two additions to the readme.txt so that the next person will not face the same problems

  • I will modify the readme file accordingly to make it more clear.

    It did assume that your java environment was properly setup to point to the java compiler and JRE prior to using the sample.

    It does say the following in the README:

    You can also run this from within Visual Studio 2010 by opening the property page,
    and on the Debug tab set the property Start external program to the full path to
    your Java.exe:

    i.e. C:\Program Files (x86)\Java\jre6\bin\java.exe

    put the name of the program in the command line field:


    I will change this so that it is clear that you should replace the i.e. line
    with a value that is valid on your particular system.

  • Hi Chris,

    Could you share the code example with me .I have Microfocus 5.1 installed on IBM AIX. I have JDK 1.4 32-bit. I want to calla simple helloworld cobol program from java and pass string parameters.


  • I believe that you are running Server Express 5.1 and the Java support for this product should be in the product documentation.

    The Java support in Server Express is the same that you will find in Visual COBOL Eclipse native support, (not JVM version).

    Check out the documentation for this on-line at the following link:

    Java -> COBOL documentation for Visual COBOL Eclipse Unix
  • Thanks for the reply Chris.

    Inorder to use java support we should use cobjrun command to run the java code. But my requirement is to use java in the command line not cobjrun.

    I think if we directly use java to call cobol we should use cobjrun in the command like. But if we use a C program which inturn calls cobol which can be used in JNI codeing.

    I want invocation to happen in the following way

    Java --> C --> Cobol

    C has utilitues like cobinit(), cobcall() and cobtidy. There are few exampls which shows how to achive this in documentation but they dont provide proper compiler options or directives which can be used.

    This C code and Cobol has to be compiled as shared objects which can be used in JNI by setting LIBPATH.

    Could you do the needfull in this regards.