Welcome to All Things Warehouse Builder

OWB – Calling Java from Process Flows

David Allan

Although the doc shows how to call java from process flows it still may not be clear enough..or even correct, here’s a quick illustration to plug the gap. The section on the JAVA activity is here just in case you didn’t know. Below is the simple example java class I fabricated…

public class javatest {
public static void main(String args[]) {
  System.out.println("In main of my java, with " + args.length + " arguments.");
  for (int i = 0; i < args.length; i++) {
    System.out.println("  arg  " + i + " : " + args[i]);
  if (args.length == 2) {
    int rslt = new Integer(args[0]) + new Integer(args[1]);

The java I will call is the static main method which takes an array of arguments and adds the first and second argument and uses that as the status. A silly example I know…but at least you see how parameters are passed into and out of the java call. There is also some debug to print the parameters etc so you can see where it goes in OWB. I compiled this class with JDK 1.5 (it must be 1.5 or less than) and jar’d the class file into a jar file.



The classpath, class_name and result_code parameters to the JAVA activity are pretty much standard as you would setup any activity in process flow. The parameter passing into the java activity is done via the PARAMETER_LIST activity parameter, see the value ,$(PARAM1),$(PARAM2) this uses the custom parameters PARAM1 and PARAM2 that I added to the JAVA activity in my flow.

In the above screenshot I have tried to show all of the important parts for configuring this example, the JAVA activity input parameters are bound to the process flow parameters PROC_ARG1 and PROC_ARG2 respectively.

So when I execute the flow, the arguments used will be passed to the java class. So if I pass 0 and 0 for the arguments the result of the java will be 0+0, 0 is a success code for the java activity. I can see what happened in the audit, I can see the process parameters and the activity parameters, I can also see the std output from the java, see the ‘Execution Details’ dialog and the Log panel for that output…


If I execute the process flow passing the values 1 and 2, then the result of the java is 1+2 which is an error code in java. See below for when the values 1 and 2 are passed ….


There is another parameter that has not been used and that was the RUN_DIRECTORY parameter, this is simply the working directory to where the java command is invoked from. So this is course grained integration of java using process flows, in 11gR2 its also possible to invoke EJBs from a process flow, and there are other integration techniques from java stored procedures or tables functions to java in 11gR2 Code Templates.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.