When linking C/C++ applications the link options described in section "Implementation of a native method in C++" must be used.
With JENV a runtime adapter is provided which has to be linked with C applications which need to call Java via the invocation API (part of the JNI). This adapter contains the functions of the Invocation API as well as the adapter to the thread-safe C and C++ runtime system and to the thread-safe socket library.
The runtime adapter is available in an optimized variant, as is used in java. The runtime systems are located in PLAM libraries which are part of the scope of delivery of JENV:
For S390:
SYSLNK.JENV.090.GREEN-JAVA.
For X86:
SKULNK.JENV.090.GREEN-JAVA
When linking an application with this runtime adapter, it must also be borne in mind that, due to the long names which occur in Java, this runtime system is of LLM type 4. It is therefore essential that the compiler option -B llm4 is used during linking. It should also be noted that the C compiler normally automatically links a CRTE during linking and in the case of C++ a standard library. This must be prevented to avoid any conflict with the thread-safe runtime system already contained in the runtime adapter. This is achieved with the Kno_link_stdlibs option. For the same reason, no socket library can be explicitly linked and nor can any tools library. During linking, the options -lc, -lsocket or -ltools should therefore never be used.
Under POSIX a C application can be linked as follows with JENV:
export BLSLIB00='$.SYSLNK.JENV.090.GREEN-JAVA' cc -Kno_link_stdlibs -B llm4 -o <program> \ <objects> -l BLSLIB
The linked program can then be run without further precautions although naturally it needs a completely installed JENV under the standard installation path. If a Java installed elsewhere is to be used, the environment variable JAVA_HOME must be set to the installation path of the Java runtime environment (see chapter "Environment variables").
The cc command implicitly links the POSIX linkage option. If linkage is not carried out under the shell using the cc command, but under the BS2000 command line interface using BINDER, this option must be linked from $.SYSLNK.CRTE.POSIX.
In order to use the BINDER to obtain the required LLM4 format when using a OSD V3 for production you must specify the operand
FOR-BS2000-VERSIONS=*FROM-OSD-V4 in SAVE-LLM . The objects can also run on OSD V3.
This procedure applies equally for C++ applications, in which case the command CC with the options specified above is to be used for linkage.
An application that explicitly calls the C interfaces of the POSIX sockets may not link the modules of the socket library but must link the LIBSOCKET module from SYSLNK.JENV.090.GREEN (or SKULNK.JENV.090.GREEN).