Programming using the BIRT Reporting APIs : Generating reports from an application : Preparing to generate the report : Adding to the report engine’s class path
 
Adding to the report engine’s class path
Some report designs require access to external Java classes. The BIRT Report Engine uses class path information from various settings in its environment to locate the external classes. BIRT supports defining some of these locations by setting properties programmatically on the application context or on the EngineConfig object, or with the Java System class. To set the properties, use constants from the org.eclipse.birt.report.engine.api.EngineConstants class. To set a property on the application context, use the EngineTask object or the EngineConfig object, as shown in the following lines of code, where MyClass is the class that starts the report engine:
configOrTask.getAppContext( ).put
( EngineConstants.APPCONTEXT_CLASSLOADER_KEY, MyClass.class.getClassLoader( ));
To set a CLASSPATH property on the EngineConfig object, use code similar to the following lines. The property value must be a valid CLASSPATH.
config.setProperty( EngineConstants.WEBAPP_CLASSPATH_KEY,
"c:/myjars/jar1.jar;c:/myclasses" );
To use the Java System class to set a CLASSPATH property, use code similar to the following lines. The property value must be a valid CLASSPATH.
System.setProperty( EngineConstants.WEBAPP_CLASSPATH_KEY,
"c:/myjars/jar1.jar;c:/myclasses" );
BIRT searches locations for external classes in the order shown in the following list:
*The CLASSPATH for the report engine plug-in.
*The CLASSPATH of the parent class loader that is set as the EngineConstants.APPCONTEXT_CLASSLOADER_KEY. Define this property on the application context.
*The CLASSPATH set as EngineConstants.WEBAPP_CLASSPATH_KEY. Define this property using the Java System class or on the EngineConfig object.
*The CLASSPATH set as EngineConstants.PROJECT_CLASSPATH_KEY. Define this property using the Java System class or on the EngineConfig object.
*The CLASSPATH in EngineConstants.WORKSPACE_CLASSPATH_KEY. Define this property using the Java System class or on the EngineConfig object.
*JAR files included in the report design.