Highlighted
Absent Member.
Absent Member.
4578 views

Visual Cobol Sample With Java

Jump to solution

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

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

There are in VisualCobol download this sample or not?

Thanks.

Cláudio Miguel Müller

claudiomiguelmuller@hotmail.com

www.meugibi.com

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual Cobol Sample With Java

Jump to solution
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.

View solution in original post

0 Likes
11 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual Cobol Sample With Java

Jump to solution
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
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual Cobol Sample With Java

Jump to solution
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.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Visual Cobol Sample With Java

Jump to solution
Chris,

I am interested in this example. Could you please mail it to wilco.veltmaat@ordina.nl

Greetings

Wilco
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual Cobol Sample With Java

Jump to solution
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.

Thanks.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Visual Cobol Sample With Java

Jump to solution
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:
.;C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar
;C:\PROGRA~1\IBM\SQLLIB\java\sqlj.zip;C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license
_cu.jar;C:\PROGRA~1\IBM\SQLLIB\bin;C:\PROGRA~1\IBM\SQLLIB\java\common.jar;D:\Mic
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
🙂

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual Cobol Sample With Java

Jump to solution
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:

arrays

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.

Thanks
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Visual Cobol Sample With Java

Jump to solution
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.



Regards
Hithesh

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Visual Cobol Sample With Java

Jump to solution
My Email id pn.hithesh@tcs.com
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual Cobol Sample With Java

Jump to solution
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
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Visual Cobol Sample With Java

Jump to solution
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.


Hithesh
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Visual Cobol Sample With Java

Jump to solution
Unfortunately removing the need for cobjrun on Unix is not possible mainly due to use to issues with the JVM's architecture itself and ours not lining up.

For example on AIX our runtime requires the use of runtime linking and loading (ld -brtl) and IBM's java trigger is linked without it. On HP-UX some JNI routines only worked when linked into the main exe, so on this platform cobjrun is also required. Other generic Unix related issues are also prevalent in stopping us from dropping the need for cobjrun, include System.load not load symbols as global.. which we need.. and trust me when I say we have a couple other nastiest issues too..

Anyway, the upshot of this although I would love personally to live without cobjrun we are stuck with it.

If it makes you feel any better we have consulted with both IBM and Sun (nee Oracle) on the subject and this is the approach recommended by them.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.