Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
JasperReports 3.5 for Java Developers

You're reading from  JasperReports 3.5 for Java Developers

Product type Book
Published in Aug 2009
Publisher Packt
ISBN-13 9781847198082
Pages 368 pages
Edition 1st Edition
Languages

Table of Contents (17) Chapters

JasperReports 3.5 for Java Developers
Credits
About the Author
About the Reviewers
Preface
1. An Overview of JasperReports 2. Adding Reporting Capabilities to our Java Applications 3. Creating your First Report 4. Creating Dynamic Reports from Databases 5. Working with Other Datasources 6. Report Layout and Design 7. Adding Charts and Graphics to Reports 8. Other JasperReports Features 9. Exporting to Other Formats 10. Graphical Report Design with iReport 11. Integrating JasperReportswith Other Frameworks Index

Chapter 2. Adding Reporting Capabilities to our Java Applications

We can easily add reporting capabilities to our Java applications by taking advantage of the classes included in the JasperReports class library. JasperReports can be easily embedded into both client and server-side Java applications simply by adding the required libraries to our CLASSPATH and calling the appropriate methods in the JasperReports API.

At the end of this chapter, we will be able to:

  • Identify the purpose of the several downloads that can be found at the JasperReports web site

  • Set up our development and execution environment to successfully add reporting capabilities to our Java applications

  • Identify the required libraries for adding reporting capabilities to Java applications

  • Identify the optional libraries that can be used to enhance the reporting capabilities of our Java applications

Downloading JasperReports


JasperReports is distributed as a JAR file that needs to be added to the CLASSPATH of any application we wish to add reporting capabilities to. JasperReports can be downloaded from http://jasperforge.org/plugins/project/project_home.php?group_id=102.

Clicking on the Download link around the center of the page will take us to the JasperReports download page on SourceForge.net.

The specific version on your screen might be different; at the time of writing, the latest stable version of JasperReports is 3.5.2.

It is not always clear what exactly is downloaded by clicking on these links; thus, we will provide a brief explanation of what each link is for.

  • jasperreports-3.5.2-applet.jar: This first download link is for a JAR file containing a subset of the JasperReports functionality. Specifically, it contains classes that can be used to display JasperPrint files, which are reports in JasperReports' native format. This file is offered as a separate download as a convenience...

JasperReports class library


For all JasperReports-related tasks, we need to add the JasperReports library to our CLASSPATH. The JasperReports library can be found under the dist directory in the project file; it is named jasperreports-3.5.2.jar. Depending on the version of JasperReports, the filename will vary.

Required libraries for report compilation

The project file described earlier contains all of the required supporting libraries. Once that file is downloaded, all the required libraries can be found under the lib subdirectory of the directory created when extracting the ZIP file. JasperReports uses these required files for XML parsing. Therefore, they are needed when compiling JRXML files programmatically, not for filling or displaying reports. JRXML files can be compiled using a custom ANT task provided by JasperReports. If we choose to compile our JRXML files using this custom ANT target, these required libraries need to be added to the CLASSPATH variable of the ANT build file. There...

Summary


This chapter covered the required and optional libraries needed to add reporting capabilities to Java applications. All the libraries covered in this chapter are needed at both compile time and runtime. The chapter provided an explanation of the different files available for downloading on JasperReports' web site and in which conditions it is appropriate to use them. We also saw which libraries are required for report compilation under a JDK and the additional libraries required when compiling JRXML templates under a JRE. Besides, we also learned which libraries are required when using JDBC datasources for our reports, and finally the libraries required when exporting our reports to several formats.

Now that we have a sound understanding of the libraries needed to work with JasperReports, we are ready to create our first report, which is what the next chapter is based on.

lock icon The rest of the chapter is locked
You have been reading a chapter from
JasperReports 3.5 for Java Developers
Published in: Aug 2009 Publisher: Packt ISBN-13: 9781847198082
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}