IBM Support

Building Java code for z/OS on other operating systems

How To


Summary

You might want to use a distributed operating system such as Windows to write and compile Java code that you intend to run on z/OS®. For example, you might want to build your code by using an Eclipse-based software development tool, and Eclipse is not available on z/OS. However, IBM® Semeru Runtime Certified Edition for z/OS contains classes that do not exist in Semeru Runtimes on other operating systems. If your Java™ code uses these classes, it will not build successfully on distributed operating systems unless you copy these extra classes to your development environment.

Environment

The extra classes are in the following .jmod files:

  • ibm.crypto.hdwrcca.jmod
  • ibm.crypto.zsecurity.jmod
  • ibm.jzos.jmod
  • ibm.crypto.ibmjcehybrid.jmod
  • java.base.jmod

Complete the following steps to create a .jar file from each .jmod file, then add it to your Java project in Eclipse. These steps assume that you have Eclipse (or an Eclipse-based application) and that your Eclipse installation contains a Java development plug-in with Semeru Runtime for Windows 10 or similar.

Steps

  1. In UNIX System Services (USS), run the following commands from a directory of your choice for each .jmod file that your code requires. The commands create a .jar file that contains the contents of the .jmod file.
    1. Extract the classes from the .jmod file to a temporary directory called extraction:

      $JAVA_HOME/bin/jmod extract --dir ./extraction $JAVA_HOME/jmods/<zos_jmod_file>
      Where <zos_jmod_file> is the name of the .jmod file. The $JAVA_HOME environment variable contains the full path of the Semeru Runtime for z/OS installation, up to and including the J11.0_64 subdirectory.
    2. Change to the classes directory then create the .jar file:

      cd ./extraction/classes
      $JAVA_HOME/bin/jar cf ../../<zos_jar_file> *
      Where <zos_jar_file> is the name of the .jar file. You can use any name you like but it’s advisable to include the name of the .jmod file so you can easily find the file later.
    3. Change to the extraction directory then add other required files to the .jar file

      cd ..
      $JAVA_HOME/bin/jar uf ../<zos_jar_file> ./legal/* ./lib/*
    4. Change to the parent directory then delete the extraction directory and its contents, which are no longer required:

      cd ..
      rm -r extraction
  2. Copy (for example by using the sftp command) the .jar files that you created to your Windows machine, to a folder of your choice.

  3. On your Windows machine, add the .jar files to your Java project in Eclipse:
    1. In the Package Explorer view, right-click your Java project, then click Build Path > Configure Build Path… . The Properties dialog for the project opens, with the Java Build Path panel showing.

    2. Click the Libraries tab.

    3. Click the Add External JARs... button to open the JAR Selection dialog.

    4. Find the .jar files in the filesystem, select all of them (for example by pressing Ctrl while clicking each file), then click Open to add the .jar files to the build path.

    5. Click Apply and Close to save your changes.

Example

After you create a .jar file from the ibm.crypto.hdwrcca.jmod file and copy it to your distributed operating system, the following example Java code builds successfully:

.

import com.ibm.crypto.hdwrCCA.provider.*;

public class hdwrccaTest {

  public static void main(String[] args) {

     System.out.println ("Testing hdwrCCA access and Semeru 11");

    com.ibm.crypto.hdwrCCA.provider.IBMJCECCA cca = new com.ibm.crypto.hdwrCCA.provider.IBMJCECCA();

    IBMJCECCA cca2 = new IBMJCECCA();

  }

}

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB45","label":"Automation"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSA3RN","label":"IBM Semeru Runtimes"},"ARM Category":[],"Platform":[{"code":"PF035","label":"z\/OS"}],"Version":"11.0.0"}]

Document Information

Modified date:
03 May 2023

UID

ibm16986587