Hello to All,
I want to use basic jasper report utility....
But facing error as mentioned below,
please help me.....I'm beginer of JReport

import java.io.File;
import java.util.HashMap;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;

import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.engine.util.JRSaver;
import net.sf.jasperreports.engine.xml.*;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.export.JRPrintServiceExporter;
import net.sf.jasperreports.engine.export.JRPrintServiceExporterParameter;
import net.sf.jasperreports.view.JRViewer;
import net.sf.jasperreports.view.JasperDesignViewer;

public class water_bill {

	public static void main(String[] args) {
		new water_bill().generateReport();


	private void generateReport() {
		JasperReport jasperReport = null;
		JasperDesign jasperDesign = null;
		JasperPrint report = null;
			//jasperDesign =JRXmlLoader.load(new File("C:/JASPER_NEW/trialJasper//trialjasper/reports/abc.java"));
			jasperReport = JasperCompileManager.compileReport("C:/JASPER_NEW/trialJasper//trialjasper/reports/abc.java");
			report = JasperFillManager.fillReport(jasperReport,new HashMap());
			JRViewer jrViewer = new JRViewer(report);
		catch(JRException e)


Error is as follow,

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:142)
at water_bill.generateReport(water_bill.java:37)
at water_bill.main(water_bill.java:25)

6 Years
Discussion Span
Last Post by vishal18

Thanks Ezzaral.....It worked.

But with new problem....

now there is a message window "The document has no pages"

whats wrong now???


I have no idea. I have not used Jasper Reports. You'll need to consult the documentation for that.


The document has no pages is an indication that your data source did not return any data. If you are using a database and SQL, check your SQL statement outside of jasper reports. If it doesn't return any rows, that is your issue.

To change the behavior of jasper reports when the data source comes back empty, see the report settings.


Also, regarding your use of the Jasper Report Compiler, the compiler is used to compile the .JRXML file into java. It is not used to compile a .java file, as you are attempting to do.

So, in general, to produce a report from java, you will use something like...

// Load the jrxml file
JasperDesign jasperDesign = JRXmlLoader.load(fileName);

// Compile the jrxml file
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

// Produce the report (fill the report with data)
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameterMap, connection);

// Export to HTML for web or view the report in JasperViewer for local

Thanks RP..
But its too late now.... :)
Now I have better hand on Jasper Reports...

thanks again for reply....

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.