Calling to and from Java programs

In relation to Java™ code, the following calls are possible:

EGL-generated Java program to EGL-generated Java program

Calling one EGL-generated program from another is as simple as invoking the Java class for the target program using a call statement. Be aware, however, of package dependencies. You must invoke a class that is one of the following:
  • Within the same package as the calling program.
  • Qualified with a package name using dot syntax.
  • Identified with a linkage option part. For more information, see Overview of linkage options part.

Non-EGL Java program to EGL program

To invoke an EGL-generated program from a non-EGL-generated Java program, do one of the following:

EGL-generated Java program to non-EGL Java program

To invoke non-EGL Java code from Java code generated by EGL, you must create an Interface part of type JavaObject. The Interface part contains function descriptions for the Java methods you wish to call.

Invoke the Java method in one of two ways:
  • If the function is marked static, invoke it using the name of the Interface part and dot syntax (interfacePart.method()).
  • Otherwise, create a variable based on that Interface part and use it in much the same way you would a library, appending the interface variable name to the name of the method using dot syntax (interface.method()).
Note that the Java class must provide a method to instantiate itself; EGL cannot instantiate a Java class.

EGL-generated Java program to DLL

You can call functions in a single, non-EGL dynamic link library (DLL) (written in, for example, C or COBOL) from an EGL Java program. The file extension for the DLL depends on your environment (examples include .dll, .so, and .sl).

You create a Library part of type nativeLibrary to act as an interface between your EGL program and the DLL. The Library part lists function names and parameters, and can use the alias property of the functions where function names do not match EGL conventions.

Access the functions by using dot syntax (library.function()) or by creating a use declaration for the library to make its functions global to your program.

EGL-generated Java program to .EXE or .BAT file

EGL provides two functions that allow you to call a system command (such as a .bat or a .exe executable file).
sysLib.callCmd()
This function transfers control to a specified executable; when the executable terminates, control returns to the calling EGL program.
sysLib.startCmd()
This function transfers control to a specified executable, then keeps running; both the EGL program and the executable run at the same time.

Feedback