JVM COBOL calling java MQ classes

In Visual COBOL 2.1 for Eclipse, I'm trying to build a JVM application that I would want to deploy on z/Linux, so created a  COBOL JVM Class, coded the statement  $set ilusing"com.ibm.mq", add a JAR to the JVM Build Path in which package com.ibm.mq exists, then wrote the line of code  

set mqmanager to new MQQueueManager(qMgrName)  in a method within the class. I cannot get the compiler/builder to recognize MQQueueManager as a class that I can access. I get the error message "COBCH0845S Unknown class 'MQQueueManager' "

I added some ilusing statements for java.lang, and can quite happily access classes like Integer.

I'm very new to this environment including object COBOL, but I think I've set up everything I should to have my class invoke a java class.

So, what am I doing wrong.

 

 

  • From what I remember about MQ's Java support it also requires PATH/LIBPATH to be setup for it to work,

    when you added the .jar file to CLASSPATH or the eclipse build path did you also setup the native

    library path too?

    re: www-01.ibm.com/.../docview.wss

  • Just to confirm. Can I set the CLASSPATH within Eclipse or in a Command Window?

  • I set up the CLASSPATH environment variable per the IBM info. But to no avail. Eclipse/Visual COBOL is finding the class in the package within the .jar file. I would just like to write the program and compile it. Then I can promote getting Visual COBOL as a full product in house. I really do not want to write the whole program/process in Java, but if I can't access the MQ class library I will have to. One thing of interest, if I go into the Java perspective in Eclipse, I can see the .jar file, the packages in it and the drill down to the classes and methods!!!!

  • I set up the CLASSPATH environment variable per the IBM info. But to no avail. Eclipse/Visual COBOL is finding the class in the package within the .jar file. I would just like to write the program and compile it. Then I can promote getting Visual COBOL as a full product in house. I really do not want to write the whole program/process in Java, but if I can't access the MQ class library I will have to. One thing of interest, if I go into the Java perspective in Eclipse, I can see the .jar file, the packages in it and the drill down to the classes and methods!!!!

  • I set up the CLASSPATH environment variable per the IBM info. But to no avail. Eclipse/Visual COBOL is finding the class in the package within the .jar file. I would just like to write the program and compile it. Then I can promote getting Visual COBOL as a full product in house. I really do not want to write the whole program/process in Java, but if I can't access the MQ class library I will have to. One thing of interest, if I go into the Java perspective in Eclipse, I can see the .jar file, the packages in it and the drill down to the classes and methods!!!!

  • Sorry meant to say Eclipse/Visual COBOL is NOT finding the class

  • I can get the following to compile without a problem in JVM COBOL on Windows by including the com.ibm.mq.jar in the build path.

        $set ilusing(com.ibm.mq)
          program-id. callMQ as "callMQ".
          data division.
          working-storage section.
          01 mqinstance type MQQueueManager.
          procedure division.

              set mqinstance to new type MQQueueManager("test")
              goback.

          end program callMQ.

  • It would seem that I'm basically doing the same as the example code above, but still not working.

    Following is my code:

         $set ilusing"java.io"

         $set ilusing"java.lang"

         $set ilusing"javax.jms"

         $set ilusing"com.microfocus.cobol.program"

         $set ilusing"com.ibm.mq"

          class-id hoganfeeds.BuildCallstoNSPforHoganData public.

         *working-storage section.

          01 working-variables.

              05  sleep-period                binary-long  value 5000.

              05  qMgrName                    pic x(8) value "REQMGR".  

              05  queue-options               binary-long.

          copy "javatypes.cpy".              

          method-id main public static.

          01 hoganfileprocessor type BuildCallstoNSPforHoganData.

          procedure division using by value args as string occurs any.

              set hoganfileprocessor to type

                      BuildCallstoNSPforHoganData::createFileProcessor

              invoke hoganfileprocessor::start

          end method.      

          method-id openqueuemgr private.

          01 mqmanager    type MQQueueManager.

          procedure division.

              set mqmanager to new MQQueueManager(qMgrName)

          end method.    

          method-id start public.

              call "CBL_THREAD_SLEEP" using by value sleep-period.

              invoke self::openqueuemgr.

          end method.

    I added an External JAR that contains the package com.ibm.mq. The info on the build path screen is

    mq-7.0.1.3.jar - C:\Documents and Settings\bundaya\IBM\mqc75

    In the Java perspective for the project I have

    JRE System Library

    COBOL JVM Runtime System

    Reference Libraries

         mq-7.0.1.3.jar

               com.ibm.mq  (with package symbol next to it)

                      MQQueueManager.class

                      MQQueueManagerFactory.class

    So Eclipse is seeing the class in drilldown but JVM Cobol is not.

  • I copied your source into a new project and commented out a couple lines that referenced methods that you didn't show and added com.ibm.mq.jar to the external JARs of the JVM Build path and it works fine.

    One thing that I noticed though is that if I added the reference JAR file when the project was first created then it was not being saved.

    Right click on your project and select Properties.

    Under Micro Focus COBOL-->JVM Build Path tab click on Libraries-->Add External Jars and select the com.ibm.mq.jar file. Mine is under C:\Program Files (x86)\IBM\Websphere MQ\java\lib.

    My project looks like:

  • Everything looks very similar, the difference I believe is that I received the Websphere stuff from another member of staff in a .zip file that extracted out to a .jar file called mq-7.0.1.3.jar. Within that jar file is the package com.ibm.mq containing the classes.   I do not have a com.ibm.mq.jar file.

    Should I be coding my "ilusing" statement differently?