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"
basedir=".">
<description>Previews our First Report XML Design</description>
<property name="file.name" value="FirstReport"/>
<!-- Directory where the JasperReports project file was extracted
needs to be changed to match the local environment -->
<property name="jasper.dir"
value="/usr/local/share/java/jasperreports-1.1.0"/>
<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"/>
</fileset>
</path>
<target name="viewDesignXML"
description="Launches the design viewer to preview the XML
report design.">
<java classname="net.sf.jasperreports.view.JasperDesignViewer"
fork="true">
<arg value="-XML"/>
<arg value="-F${file.name}.jrxml"/>
<classpath refid="classpath"/>
</java>
</target>
</project>
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