Preparations

Before programming with the Engine Bean, you need to import the Engine Bean classes by adding the following import statements to the beginning of your program. The first import statement is added to import the bean class:

import jet.bean.*;
import java.awt.*;
import java.awt.event.*;

Then, you need to create an instance of the Engine Bean.

Note: When you call the Engine Bean in your program, you should first set the JReport Runtime user ID and key.

bean.setUID("JReport Runtime User ID");
bean.setKey("JReport Runtime Key");

After the object has been created, set the reporthome, report file, catalog file, result file (if necessary), and parameter values (if necessary).

bean.setReportHome("C:\\JReport\\Designer");
bean.setReportName("C:\\JReport\\Designer\\Demo\\Reports\\SampleReports\\CustomerAnalysis.cls");
bean.setCatName("C:\\JReport\\Designer\\Demo\\Reports\\SampleReports\\SampleReports.cat");
bean.setTimeZone("CST");
bean.setParamValues("p_StartDate=01/01/2006,p_EndDate=12/31/2007");
bean.setResultFile("C:\\JReport\\Designer\\temp\\CustomerAnalysis.rst");
bean.runReport();

Note: You can run or export a self-contained report by calling JReport Engine Bean. Suppose you want to run a self-contained report called CustomerAnalysis.clx, which is saved in C:\JReport\Designer\Demo\Reports\SampleReports. You will not need to set the catalog name in your code, you can just set the report home, report file, and specify whether to output the debug or error information (if necessary) and log file (if necessary) as below:

bean.setReportHome("C:\\JReport\\Designer");
bean.setReportName("c:\\JReport\\Designer\\Demo\\Reports\\SampleReports\\CustomerAnalysis.clx")
bean.setShowInfoLevel( bean.vDebug | bean.vError );
bean.setLogFile("");
bean.runReport();

With the JReport Engine Bean object, you can manipulate and access many reports, without needing to create a bean for each one. JReport Engine Bean provides many useful methods, which you can call before or after the runReport() method.