Book Image

JasperReports 3.5 for Java Developers

Book Image

JasperReports 3.5 for Java Developers

Overview of this book

Do you want to create easily understood, professional, and powerful reports from disordered, scattered data using a free, open source Java class library? If your answer is yes, this book on JasperReports is what you are looking for. JasperReports is the world's most popular embeddable Java open source reporting library, providing Java developers with the power to easily create rich print and web reports. The book has been fully updated to use JasperReports 3.5, the latest version of JasperReports. Previously accepted techniques that have now been deprecated have been replaced with their modern counterparts. All examples in the book have been updated to use XML schemas for report templates. Coverage of new data sources that JasperReports now supports has been added to the book. Additionally, JasperReports can now export reports to even more formats than before and exporting reports to these new formats is covered in this new edition of the book. This book shows you exactly how to get started, and develop the skills to get the most from JasperReports. It introduces you to the latest version of JasperReports, and gets you creating complex and elegant reports. The book steers you through each point of report setup, to creating, designing, formatting, and exporting reports with data from a wide range of data sources, and integrating JasperReports with other Java frameworks. Starting with the basics of adding reporting capabilities to your application and creating report templates, you will first see how to produce your reports through the use of JRXML files, custom ANT targets, and then preview them in both the web browser and the native browser of JasperReports. Getting data into your reports is the next step, and you will see how to get data from a range of data sources, not only databases, but XML files, and Java Objects, among others. You will create better looking reports with formatting and grouping, as well as adding graphical elements to your reports. You will export your reports to a range of different formats, including PDF and XML. Creating reports will be made even easier with a walkthrough of the iReport Designer visual designing tool. To round things off, you will see how to integrate your reports with other Java frameworks, using Spring or Hibernate to get data for the report, and Java Server Faces or Struts for presenting the report. All examples have been updated to use XML schemas. New export formats, such as OpenDocument Text, and new data sources now supported by JasperReports are now covered in this updated edition.
Table of Contents (17 chapters)
JasperReports 3.5 for Java Developers
Credits
About the Author
About the Reviewers
Preface
Index

What exactly is JasperReports?


JasperReports is an open source Java library designed to aid developers with the task of adding reporting capabilities to Java applications. It is not a standalone tool and therefore it cannot be installed on its own. Instead, it is embedded into Java applications by including its library in the application's CLASSPATH. Being a Java library, JasperReports is not meant for end users. Rather, it is targeted towards Java developers who need to add reporting capabilities to their applications.

JasperReports is licensed under the Lesser GNU Public Library (LGPL). This license was chosen for JasperReports because, unlike the GPL, it allows JasperReports to be used in both open source and closed source applications. Applications linking to the JasperReports Java class library do not need to be open source. However, if you are considering making modifications to the existing JasperReports source code, then your modifications will have to be released under the LGPL. Refer to http://www.gnu.org/copyleft/lesser.html for the complete license.

Although JasperReports is primarily used to add reporting capabilities to web-based applications using the servlet API, it has absolutely no dependencies on the servlet API or any other Java EE library. It is, therefore, by no means limited to web applications. There is nothing that stops us from creating standalone desktop or command-line Java applications to generate reports with JasperReports. After all, JasperReports is nothing but a Java class library providing an API to facilitate the ability to generate reports from any kind of Java application.

JasperReports requires a Java Development Kit (JDK) 1.4 or newer in order to successfully compile applications incorporating the JasperReports Java class library and a Java Runtime Environment (JRE) 1.3 or newer to successfully execute these applications. The older versions of JasperReports required a JDK to successfully execute JasperReports applications (strictly speaking, JasperReports requires tools.jar to be in the CLASSPATH, and tools.jar is included in the JDK, not JRE). As of version 0.6.4, however, JasperReports is bundled with the Eclipse Java Development Tools (JDT) compiler and no longer needs a JDK to execute deployed applications. Examples in this book were developed using JDK 1.6 but should compile and execute successfully with any JDK or JRE supported by JasperReports.