INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Cobol, Java Distributed Programming

Cobol, Java Distributed Programming

(OP)
I am a java programmer. I  need to know how to run a java program that passes parameters to a Cobol program. When the Cobol program is finished, it will pass a value back to the java program. I am trying to not consider using JNI.

At work, we use Microfocus cobol.  Microfocus has a tutorial called 'Distributed Computing'. The tutorial has a sample java program called 'SimpleDemo' & sample Cobol program called 'Legacy'. I compiled both the Java & Cobol programs separately. I also did the recommended setup per the tutorial. I added to my classpath the mfcobol.jar file.

When i ran the java program SimpleDemo, I got the error message:
"Exception in thread 'main' java.lang.UnsatisfiedLinkError: no cbljvm_sun in java.library.path.

The only thing I can think of is that, I don't put the cobol program in a library, like the tutorial suggests. I access the cobol program by referring to its path on my pc. My company doesn't use libraries to store it's cobol programs.

A cobol programmer at work tried the same code & got the same java error message as I did.

The cobol program "legacy" :

identification division.
environment division.
input-output section.
data division.
working-storage section.
copy "javatypes.cpy".
 01 wsResult       jint.

 linkage section.
  01 wsOperand1     jint. *> type defined in javatypes.cpy
  01 wsOperand2     jint.
  01 wsOperation    pic x.

 procedure division using wsOperand1 wsOperand2 wsOperation.
    evaluate wsOperation
      when "a"
         add wsOperand1 to wsOperand2 giving wsResult
      when "s"
         subtract wsOperand1 from wsOperand2 giving wsResult
    end-evaluate

  exit program returning wsResult.

--------------------------------------

Java program is :

import mfcobol.* ;

import java.io.IOException;
import java.io.*;
import java.awt.*;
import java.util.*;
import java.applet.*;
import java.lang.Object;
import java.lang.String;

// add mfcobol.jar to classpath.

class jc

{

  public static void main(String argv[]) throws Exception
  {
    if (runtime.cobload("C:\\JavaHowTo\\JniCobol\\legacy",
                     null) != 0) {
      System.out.println("Could not load library\n") ;

    }
    else   {
          System.out.println("Library loaded successfully\n") ;
    }

    Object theParams[] = {new Integer (4),
                            new Integer(7),
                            new Byte((byte)'a')} ;
          int i = runtime.cobcall_int("legacy", theParams) ;
          System.out.println(i) ;
          theParams[2] = new Character ('s') ;
          i = runtime.cobcall_int("legacy", theParams) ;
          System.out.println(i) ;

  }

RE: Cobol, Java Distributed Programming

What O.S.? Which version of Micro Focus? How did you compile your COBOL program (*.int or *.gnt or *.dll/*.so)?
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close