gcotis
gcotis

Reputation: 117

Calling a Java Program from Cobol

I'm trying to communicate Java and Cobol. I need to call a Java program (with paramaters) from Cobol.

I read some documentation from Microfocus: http://supportline.microfocus.com/documentation/books/nx40/dijafc.htm http://supportline.microfocus.com/documentation/books/nx40/dijaco.htm

But I didn't find a real solution, because I need to call an entire program and not a Java Class.

Thanks in advance.

Upvotes: 0

Views: 3532

Answers (2)

Smitt
Smitt

Reputation: 176

The link you posted explains very well about how we can instantaite a java class. If you are concerned about parameters, then write the Java Class with parameteric constructor and pass the parameters while you instantiate the Class from Cobol.

If you are confused about Java Class and Java Program, then you need to know that Java programs are compiled into .class files at the most you have executable jars containing .class files. But there is nothing like .exe for java.

Upvotes: 1

MrSimpleMind
MrSimpleMind

Reputation: 8587

Below is a sample program that will launch an EXE from within a COBOL97 application.

Check CallEXE demo in http://www.netcobol.com/support/code-samples/


When it comes to Microfocus...

One can not CALL an EXE from a Micro Focus INT or GNT, but you can CALL a Non-mainframe program (Micro Focus dialect in MFE) and issue a shell to DOS and from there either execute a command line that executes the EXE or execute the EXE file directly passed on the Micro Focus CALL (x'91' function code =35).

Also, you will not get back any passed parameters since once the DOS shell is closed, no parms can be returned. So the best way to get parms back is to write them to a file.

I am including a sample program that shows this x'91' FC=35 call. As you can see, you can execute a batch file or a command or an EXE directly.

Working-Storage Section.

1  Cmd-Line-Str.

 2              Pic X(45)

  *      value 'RUN $IMSDIR\PCIMS RUNIMS BMP,DBUTIL,DEMO001T'.

  *      value 'run lorince'.

     value 'dir c:\ /o > d.d'.

2   N-1         Pic X Value Low-Value.

   1   Call-Func    Pic X Comp-X Value 35.

   1   Result       Pic X Comp-X.

   1   Cmd-Line-Len Pic X Comp-X Value 0.

   Procedure Division.

   P1.

   Display Cmd-Line-Str upon Command-Line

   Call x'91' using Result, Call-Func, Cmd-Line-Len

   If Result = Zeroes

      Display 'Call worked'

   End-If

    Goback.   

I hope the post gives you some more information, I have only mainframe knowledge and haven't tried any of this above.

Upvotes: 1

Related Questions