You are on page 1of 4

Calling custom Java classes and JAR files in ODI via Jython or Java BeanShell

Posted: June 9th, 2010 | Author: Uli Bethke | Filed under: Oracle Data Integrator (ODI) | Tags: jar, java, java class, odi | 2 Comments

First we create a simple Java class that creates and writes to a text file and save it as FileWrite.java view source print?
01 import java.io.*; 02 03 public class FileWrite 04 { 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 } } } } catch (IOException e) { e.printStackTrace(); File file= new File("C:\\MyFile.txt"); fos = new FileOutputStream(file); dos=new DataOutputStream(fos); dos.writeInt(2333); dos.writeChars("Hello World"); try { public void writeFile() { FileOutputStream fos; DataOutputStream dos;

Next we compile the .java class from the command line

view source print?


1 c:\javac FileWrite.java

Next we create a .jar file from the class view source print?
1 c:\jar cf FileWrite.jar FileWrite.class

We then copy and paste the .jar archive to the ODI drivers folder Next we restart the ODI agent. We can now call methods in this class from either Jython view source print?
1 import FileWrite 2 3 fw=FileWrite() 4 fw.writeFile()

or we can call it from the Java BeanShell view source print?


1 import FileWrite; 2 3 FileWrite fw = new FileWrite(); 4 fw.writeFile();

If you want to master scripting in ODI get the following books. Java BeanShell Scripting in Java: Languages, Frameworks, and Patterns Jython The Definitive Guide to Jython: Python for the Java Platform. Jython Essentials (OReilly Scripting)

Hi, I have written java program which i want to run though ODI.My questions are as follows: 1. At which place i need to put my code and jar files i.e. do i need to put my code on the machine where ODI is installed?
You need to place the JAR file at ODI's driver folder.

2. which technology to use i.e. jython or java bean shell.


You can use Jython or Java bean shell . I prefer Jython .

3. Commands format for jython or java bean shell.


In your procedure , set the technology to Jython . Write normal java commands ... like import <your_class_name> <you operation etc>

You might also like