How to Call Java from Natural and Vice versa without using any middleware / integration layer

Natural Calling java # JAVA CALLING Natural

I am creating new Java functionality which will run on Mainframe ZOS. (Now we can run Java on IBM Mainframe.) we are a big Natural Adabas shop - just wondering when my natural and Java applications will run on the mainframe - do I need to have any middleware to communicate between Java and natural and vice versa? when I checked the documentation it says from natural to call Java we can use JNI - but we need to create some “C” wrapper to access Java. Java to Natural - Via Entire X. These are all very old posts.

Is there any update in the Natural / Adabas products where we can access Java which is running on the mainframe?

Can someone help with the steps to implement - Call Java directly from Natural and vice versa without any middle/ware and any C wrapper.

Thanks in advance - hoping will get a positive response

With EntireX SDK you can generate a “Java Class I/O interface (that’s the new term to replace term Wrapper)”. Use the SDK to extract the IDL from a NATURAL subprogram first then you can generate the IO interface. You will need to run NATURAL RPC server to expose the NATURAL subprogram as a service.

Eugene (Gene) Miklovich

ADABAS/NATURAL Systems Support and DBA

Cell: 916-202-7047

Normal Hours: 8am-4pm E.T.

Please call or text if assistance needed outside these hours.

Hello Eugene,

Thank you for your response; it is greatly appreciated.

Given that both the Natural application and the new Java application are running on the mainframe, do I still need EntireX? I am exploring a solution similar to JNI, which would establish bidirectional communication between Natural and Java. Could you please advise if this solution makes sense?

I was under the impression that EntireX is required only for interfacing external non-mainframe systems with Natural on the mainframe.

Mukunthan Sundararajan

While it is certainly possible I am not aware of any direct calling.

Both JAVA and NATURAL like to be in control.

In reality neither one has executable binary modules. They both use P-CODE.

The P-CODE is interpreted by a supervisor (in JAVA it is a JVM) that is in control.

So the JAVA objects runs under a JVM and the NATURAL Object under a NATURAL Session (let’s call it a NVM).

So EntireX is needed to communicate. Even on mainframe.

I have used it to communicate between NATURAL and COBOL.

Eugene (Gene) Miklovich

ADABAS/NATURAL Systems Support and DBA

Cell: 916-202-7047

Normal Hours: 8am-4pm E.T.

Please call or text if assistance needed outside these hours.

This appears to be nearly the same topic as raised by “ak_kannan Kannan_Alagarsamy” - perhaps you could review that discussion.

As there is no direct “call” function between Java and Natural (as Eugene has explained), a middleware of some sort is needed, whether it is passing sequential files back and forth or using a messaging tool like EntireX.

EntireX can either use web services or Java / Natural Wrappers to call to/from Java and Natural. Wrappers allow each tool to use it’s own native objects to communicate with the other platform. Web services have a bit more overhead, but allow more portability - Java calling Natural RPC services exposed as EntireX web services does not need an EntireX runtime, but the Wrappers approach will need an EntireX runtime available.

1 Like

Thank you, Douglas - I am still trying to make it work using my beating around-bush solution :slight_smile: I am not sure whether I will win or lose. This is what I am trying

Natural Program Calling COBOL - This works fine.
COBOL Program Calling Java on z/OS - This also works fine.
COBOL Calling Natural - No issues here.
Java Calling COBOL - This works without any problems.
The problem arises when I try to combine these scenarios:

Natural calls COBOL, and COBOL calls Java: This sequence results in a NAT9974 error (Natural termination forced by abend 4088 RC=03EC), indicating memory exhaustion. Based on my research, this seems related to LE (Language Environment) and RENT-REENTER settings.
Details:

I’m not using any middleware; instead, I use JNI for COBOL to call Java, which works as expected.
The issue seems to be that Natural does not properly wait for COBOL to complete the Java call and return, leading to the error.
I’ve tried adjusting memory regions (0M, 8M, 128M) with no success. I’m considering an alternative approach where JNI calls C, and Natural uses C to invoke Java.

I don’t know who will signal natural that Cobol is calling Java and give some data from Java to natural.

If this solution works - will keep you all posted. if you see any flaw in the solution please advice me

Hello,

Mukuthan, this reads like you are creating your own middleware using COBOL.

How will you call it?

Greetings

Hello Wolfgang Rohlfs,

Thank you for your reply.

We are not trying to create our middleware using COBOL. Our POC aims to call a Java method from Natural via COBOL without using messaging or middleware.

Here’s what we’re attempting:

  1. We can run Java on z/OS, and COBOL can call Java using JNI on z/OS.
  2. We want to invoke a Natural program that calls a COBOL program, which in turn calls a Java program and returns a result to COBOL and then back to Natural.
  3. Individually, the following work well:
  • Natural to COBOL: Passing parameters from Natural to COBOL works fine.
  • COBOL to Java: Passing parameters from COBOL to Java works fine. in this, able to process and return value to COBOL.

However, when executing the complete thread, it fails:

  1. Initially, we encountered a Getmain error due to the Region parameter in the job. We set it to 0, resolving this issue.
  2. We confirmed that Natural can pass parameters to COBOL and COBOL can read these values, (its proven solution).
  3. When COBOL tries to invoke the Java method by passing the parameter received from Natural via the linkage section, it fails, stating it cannot find the Java method / unable to invoke the Java method.

I am unsure why the end-to-end process fails, as individual calls (Natural to COBOL and COBOL to Java) work. Do we need additional parameters at the Natural system level to facilitate this hybrid call? I am testing this in Batch mode.

Do you have any advice on whether this approach will work? I want to keep communication simple between the languages without introducing middleware or messaging components. If my COBOL program can successfully locate and invoke the Java method, the process should complete with the value returned to COBOL and then to Natural.

Do you recommend this solution, and is it worth pursuing this POC?

Thank you for your guidance.

Best regards,

Software AG does not have any implementation in NAtural to invoke Java Method directly - when Java runs on Mainframe zOS? like what IBM did - using JNI to invoke the Java method from COBOL. or I don’t know whether I am missing something. When all are running on the mainframe - why do we need Entirex or Messaging to invoke and pass the parameter between the languages?

If I am correct, I think we can use JNI with C to communicate between Natural and Java without any middleware.

please let me know if there is any alternative solution when all are on the mainframe. kind of Natural Parms setting or some tweaking is required etc.