Skip to main content

Simple Java Application


Simple Java Application



Creating the code

This document shows how to create your first program using Windward Reports. To keep it very simple it creates a command line application. The sample here is created using IntelliJ running on Windows XP.


  1. Create a new project using your IDE. Here is the project after it was created in IntelliJ and a single class is created with a main method.Simple_Java_Application1.jpg
  2. Add all of the Windward Reports jar files to the libraries for this project. These are found in c:\Program Files\Windward Studios\Windward Reports Java Engine\lib if you installed to the default directory when installing Windward Reports.

  3. Copy the template and data files from C:\Program Files\Windward Studios\Windward Reports Java Engine\samples\sample1 to the directory with the sample report.
  4. You also need to copy to this directory.Simple_Java_Application5.jpg
  5. To keep things simple, there is no error checking and this will always create a PDF report. To see a complete version of this simple approach, please look at in sample 1.

  6. Passing templates and xml data to the engine and getting the created report back is all done with streams. So the template and data can come from anywhere and the created report can be passed back to any destination. (SQL data sources is handled via connections.)

The Code

Running the Program

  1. Run the program as:
  2. java SimpleReport "Purchase Order Template.rtf" report.pdf order.xml
  3. This will generate the report in the file report.pdf. This is all there is to it, at it’s simplest Windward Reports can be invoked using 4 lines of code.


import net.windward.xmlreport.*;
import net.windward.datasource.dom4j.*;


public class SimpleReport {

 public static void main(String[] args) throws Exception {

  System.out.println("Template file: " + args[0]);
  System.out.println("Report file: " + args[1]);
  System.out.println("Data file: " + args[2]);

  // create the report object, giving it the template and output streams
  ProcessPdfAPI report = new ProcessPdf(new FileInputStream(args[0]), new FileOutputStream(args[1]));

  // initialize the report object

  // apply a datasource to the template. This can be called multiple
  // times, passing in numerous datasources.
  report.processData(new Dom4jDataSource(new FileInputStream(args[2])), null);

  // create the output report.

  System.out.println("Report creation successful!");

  • Was this article helpful?