Jump to content
JasperReports Library 7.0 is now available ×

java.lang.ClassCastException


2005 IR Help

Recommended Posts

By: Alex - aartini

java.lang.ClassCastException

2005-06-21 12:49

I'd like to execute a small java program that run a compiled report.

I imported all package net.sf.jasperreports and in main I have:

 

String fileName = "c:test.jasper";

 

try {

JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(fileName);

JasperPrintManager.printReport(jasperPrint,true);

 

}

catch (JRException e)

{

e.printStackTrace();

System.exit(1);

}

catch (Exception e)

{

e.printStackTrace();

System.exit(1);

}

 

program returns a ClassCastException in net.sf.jasperreports.engine.JasperReport, but I don't know why.

Anyone can help me?

 

Thanks

 

 

 

 

By: C-Box - c-box

RE: java.lang.ClassCastException

2005-06-21 22:43

Well a file with the extension ".jasper" is a compiled Report... not a filled one.... you must load this report and call the fill-method where you pass in your parameters and datasource/connection...... what you get is a JasperPrint-Object that can be printed or viewed or exported..... so what you have to do is to load your compiled report and fill it... or load a so call ".jrprint" file... this is a filled report that could be loaded and printed directly

 

hth

C-Box

 

 

 

 

By: Alex - aartini

RE: java.lang.ClassCastException

2005-06-23 14:18

Could you please, explain me a step by step example?

 

Thanks

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...