Mozilla Skin

RunJasperReports Usage

From GTwM

Back to main page

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 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. Mandatory options are listed first.

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, mysql and firebird are recognised
-reports reportslist A comma separated list of .jrxml JasperReport files to generate reports from
-dbhost host (optional): Address (IP address or domain) of the database. If not specified, a local database is assumed
-output outputtype (optional): e.g. 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. Defaults to pdf
-folder outputfolder (optional): A location on the filesystem to save generated reports to
-filename outputfilename (optional): Filename for generated report(s). If multiple reports are specified with the -reports parameter, the name of each report will be appended to outputfilename otherwise outputfilename will be used on it's own. A relevant filetype suffix will also be automatically appended, e.g. .pdf, .html
-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
-emailsubject emailSubject (optional): Subject line, currently no spaces are allowed
-emailhost host (optional): Address of email server to use, defaults to localhost
-emailuser username (optional): For use if authentication is required by the email server
-emailpass password (optional): For use if authentication is required by the email server
-params parameterlist

(optional): 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