Java Reference
In-Depth Information
The utility is a standalone Java application included in the JasperReports JAR file. The
class that needs to be executed is net.sf.jasperreports.view.JasperDesignViewer .
The easiest way to execute this class is to use an ANT target, including all the required
libraries in the CLASSPATH. This is the approach that is used in the JasperReports
samples, included in the project ZIP file, and by us as well. The following ANT build
file will launch the JasperDesignViewer to preview our report:
<project name="FirstReport XML Design Preview" default="viewDesignXML"
<description>Previews our First Report XML Design</description>
<property name="" value="FirstReport"/>
<!-- Directory where the JasperReports project file was extracted
needs to be changed to match the local environment -->
<property name="jasper.dir"
<property name="classes.dir" value="${jasper.dir}/build/classes"/>
<property name="lib.dir" value="${jasper.dir}/lib"/>
<path id="classpath">
<pathelement location="./"/>
<pathelement location="${classes.dir}"/>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<target name="viewDesignXML"
description="Launches the design viewer to preview the XML
report design.">
<java classname="net.sf.jasperreports.view.JasperDesignViewer"
<arg value="-XML"/>
<arg value="-F${}.jrxml"/>
<classpath refid="classpath"/>
This ANT build file must be saved in the same directory as our JRXML file. It is
recommended that the JRXML file be saved with the report name as its file name.
The report name is defined in the <jasperReport> root element. In the JRXML file,
we chose to use FirstReport as the report name. Therefore, the recommended file
name for this report template is FirstReport.jrxml .
Search WWH ::

Custom Search