Example 1: Accessing a record for a UDO and registering the UDO with the report system

This example describes how to access a record for your UDO and how to register your UDO with the report system.

  1. A UDO needs to implement at least four classes from JReport. The four classes are for template, result, creator and render files respectively.
  2. Compile the Java files.

    To compile these four Java files, you should add report.jar and JREngine.jar with their path into the class path. For example, use the following command:

    Javac -classpath "C:\JReport\Designer\lib\JRengine.jar;C:\JReport\Designer\lib\report.jar;C:\test "MyDbFld.java

    Here it is assumed that JReport Designer is installed to C:\JReport\Designer. The Java files for the example are in C:\test\myudo.

  3. Modify the udo.ini file in the <install_root>\lib directory by appending the four classes as follows:
    Begin
    name=MyDbField
    template=myudo.MyDbFld
    resultobject=myudo.MyDbFldRst
    resultcreator=myudo.MyDbFldCreator
    resultviewer=myudo.MyDbFldRender 
    End
  4. Edit setenv.bat in <install_root>\bin by appending the path of the four classes to the batch file's ADDCLASSPATH variable. Assume that the four classes are located in D:\test\myudo.

    set ADDCLASSPATH=%JAVAHOME%\lib\tools.jar;D:\test;

  5. Start JReport Designer.
  6. Click Insert > UDO. You will now find a new UDO object named MyDbFld in the drop-down list of the Insert UDO dialog.