Previous Topic: Configure the Java ModuleNext Topic: Using a JavaObject


Configure the Run Java Code Operator

You can invoke classes in an external Java Archive (JAR) file from a Run Java Code operator. The Run Java Code operator can use both operator-level and module-level JARs. You can also configure the Run Java Code operator to override module-level settings. Use the operator to leverage the functionality in your existing Java code.

Follow these steps:

  1. If you did not already configure the Java module, complete this task first. See Configure the Java Module.
  2. Configure the Run Java Code operator.

    Specify the paths to the external JARs that the Run Java Code operator uses. For each path, you can enter:

    Unless you specify a full path, the application interprets the path that you enter as a relative path.

    The operator loads the JARs listed in this field and makes them available to the Java code in the running operator. The classes defined in these JARs override the same classes specified in the module-level JARs.

  3. In addition to external JARs, enter paths to any .class files for the Run Java Code operator.
    1. For .class files in an unnamed package, enter a path that ends with the directory that contains the .class files. For example, if MyAccount.java does not belong to a package, and MyAccount.class is in:
      C:\java\tests\MyAccount.class
      

      Set the operator so it uses the following path:

      C:\\java\\tests
      
    2. For .class files in a named package, enter a path that ends with the directory that contains the root package. The root package is the first package in the full package name. For example, if MyAccount.java belongs to the package com.ca.tech and MyAccount.class is in:
      C:\java\othertests\com\ca\tech\MyAccount.class
      

      Set the operator so it uses the following path:

      C:\\java\\othertests
      

    Note: Specify the path to a folder as a full path or as a relative path to CA Process Automation User Resources. Do not specify an http path. Specify the path to a folder so it loads .class files, not JAR files. Unlike .class files, each JAR file requires a separate path that ends with the JAR file (not the directory where it resides).

  4. (Optional) Upload the JARs you want to work with to the CA Process Automation User Resources.

    CA Process Automation automatically mirrors the JARs.

    Note: Resources, including user resources, are mirrored during the mirroring interval of the orchestrator or agent. Ensure that the JAR files you upload in the user resources are already mirrored before using them in the Java module operators.

  5. Specify the code to run.
  6. Specify the input parameters to pass to the Java code.
  7. Specify the output names of the variables created in the operator Java code. The output variable names must be saved in the operator dataset when the code finishes running.

    Note: CA Process Automation serializes Java objects that are not Boolean, date, integer, number, string, character, or an array of these types and saves them as JavaObjects.

  8. (Optional) Specify the logger setting of this Run Java Code operator. These settings override the module-level logger settings.
  9. Run the Run Java Code operator.

    The Java module captures exceptions or errors that are encountered during an operation and alerts the user in the Reason field of the problem operator.