Creating a binary report template

The JRXML files cannot be used directly to generate reports. They need to be compiled into JasperReports' native binary format. Compiled report templates are called jasper files. There are two ways to compile a JRXML file into a jasper file: We can do it either programmatically or through a custom ANT task provided by JasperReports.

Compiling a JRXML template programmatically

A JRXML template can be compiled into a jasper file and saved to disk by calling the compileReportToFile() method on the net.sf.jasperreports.engine.JasperCompileManager class. The three overloaded versions of the JasperCompileManager.compileReportToFile() method are listed below:

  • JasperCompileManager.compileReportToFile(String sourceFileName) ...

Get JasperReports 3.5 for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.