RunJasperReports Usage

From GTwM

Jump to: navigation, search

RunJasperReports is a command line tool to generate report output from JasperReports report definition files (.jrxml files). These files can be generated using graphical tools such as iReport and then RunJasperReports can be used to run them against a live database at any time, e.g. on a server on a scheduled basis. Output PDF/HTML is written to disk and can optionally be emailed

System Requirements

The current requirements are

  • Java installed. Tested with Java 5 and Java 6
  • A database available to generate report data, currently postgres, mysql and firebird (provisional) are supported

Installation

Download the package and uncompress to a location on your filesystem.

Usage

Inside the application folder, the command line is 'java -jar RunJasperReports.jar' followed by these options

Command Line Option Description
-dbname database Specify the database to report from
-dbuser username User to connect to the database as
-dbpass password Password for the user
-dbtype type Type of database we're connecting to, currently the values postgresql and mysql are recognised
-dbhost host (optional): Address (IP address or domain) of the database. If not specified, a local database is assumed
-emailfrom emailaddres (optional): To have a report emailed once it's been generated, specify this and the below email options
-emailto emailaddress (optional): Address to send report to
-subject emailSubject (optional): Subject line, currently no spaces are allowed
-folder outputfolder A location on the filesystem to save generated reports to. The folder name must end with a separator, e.g. '/' if on Linux, '\' if on Windows
-output outputtype    pdf to save reports as PDF files, html to save them as web pages. Note if emailing, PDF works best as images currently aren't attached when sending HTML
-reports reportslist A comma separated list of .jrxml JasperReport files to generate reports from
-params parameterlist

Parameters to pass through to JasperReports, e.g.

-params 'resident=boolean:true,name=string:Tom Jones,weight=double:96.2,age=integer:85'

Currently only those four parameter types are supported

Example command line:

java -jar RunJasperReports.jar -dbname financial -dbhost 192.168.0.2-dbuser okohll -dbpass secret -dbtype postgresql -emailfrom reports@gtwm.co.uk -emailto fd@gtwm.co.uk -subject Reports -folder /home/okohll/reports/output/ -output pdf -reports /home/okohll/reports/commission.jrxml,/home/okohll/reports/sales.jrxml
Personal tools