7.2. Compiling Reports

JasperAssistant is tightly integrated with Eclipse's resource build infrastructure. Reports are compiled in exactly the same was as it is done for regular Java files. This means that you can compile reports by using standard build actions available as shortcuts or from the Project menu. For more information please read the following Eclipse help section:

Workbench User Guide->Tasks->Building Resources

Before you can compile your reports you must activate the JasperAssistant's Report Compiler for your project. This is done with the help of a special property page accessible from the project's properties dialog. To open the dialog, right-click on your project and then select Properties option from the context menu. In the opened dialog choose JasperAssistant property page:

Figure 7.1. Project properties dialog

Project properties dialog

Report Compiler works on any project but it has a special support for Java Projects. Developing reports under a Java Project allows reports to use any class accessible in the project's classpath. This means that if needed, you can develop your report scriptlets and helper classes at the same time you develop your reports. All the build settings configured for the Java Project are taken in consideration. For more information on these setting please read the following Eclipse help section:

Java Development User Guide->Tasks->Building.

For reports that use scriptlets it is necessary to configure the project's classpath in order to include the JasperReports library. This can be easily done by adding the LIB_JASPERREPORTS variable to the class path of the Java Project. This method also ensures that the correct version of JasperReports library, as required by installed version of JasperAssistant, is used.

Figure 7.2. Project classpath

Project classpath

Report Compiler performs its task by searching for JasperReports report definition files in your project. By default, all the files with xml and jrxml extensions are considered as potential candidates for valid report definition files. This can increase the compilation time, as you might have other files with xml extension in your project. Although the Report Compiler is very fast, you should consider using jrxml extension for all your reports. If you do so, you can disable the checking of xml files from JasperAssistant's preference page:

Window->Preferences->JasperAssistant->Report Compiler

All compilation errors produced by the Report Compiler are displayed in the Problems View. Click on an error to locate the report object that is the source of the problem. Compilation errors provide the information necessary to locate the source of the problem. Most of the time, compilation errors are caused by problems in report expressions. For these errors, the message is prefixed with the name of the expression property.

After a successful compilation, a binary file with jasper extension is created in the same directory with compiled report. If needed, it can be opened in a read-only mode and saved back to the XML format. If desired, jasper files can be excluded from Package Explorer and Navigator views by using Filters option available for each of these views. Additionally, jasper files will be automatically ignored by CVS and SVN plug-ins.